npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

auto-show-hide-fields

v1.1.4

Published

A jQuery plugin to show and hide fields based on select or radio button values.

Readme

Auto Show Hide Fields

A lightweight JavaScript module to show/hide fields based on select or radio input values. This module allows you to automatically manage the visibility of form fields and apply smooth transitions, with support for callback functions when elements are shown or hidden.

Features

  • Automatically show/hide fields based on the value of select or radio input elements.
  • Supports smooth transitions with configurable duration.
  • Callbacks for custom actions when fields are shown or hidden.
  • Easy to integrate and customize with minimal setup.

Installation

You can either include the module directly in your project or install it via a package manager if you're using a module bundler (e.g., Webpack, Gulp, etc.).

Using a Module Bundler

  • Install the module via npm (if available) or manually download the .js file.
  • Import the module into your JavaScript file:
import AutoShowHideFields from 'auto-show-hide-fields';

Direct Usage (Without a Bundler)

Simply download the AutoShowHideFields.js file and include it in your HTML:

<script src="path/to/AutoShowHideFields.js"></script>

Usage

Initialization

To use the module, instantiate the AutoShowHideFields class with an optional configuration object.

const autoShowHide = new AutoShowHideFields({
    duration: 300,  // Transition duration (in milliseconds)
    autoTriggerChange: true,  // Automatically trigger the 'change' event
    onShow: (element) => {
        console.log('Element is shown:', element);
    },
    onHide: (element) => {
        console.log('Element is hidden:', element);
    }
});

Configuration Options

  • selector (default: "[data-checkvisibility]"): A CSS selector for targeting the fields that should show/hide based on other form input values.
  • duration (default: 0): The duration of the transition effect when showing or hiding elements (in milliseconds).
  • autoTriggerChange (default: true): Whether to automatically trigger the change event to initialize visibility on page load.
  • onShow (default: null): A callback function that is called when an element is shown. Receives the element as an argument.
  • onHide (default: null): A callback function that is called when an element is hidden. Receives the element as an argument.

HTML Structure

Make sure the elements that need to trigger visibility have the data-checkvisibility attribute, specifying the target elements and values.

<select data-checkvisibility="target1:yes,target2:[no|Noting]">
    <option value="yes">Noting</option>
    <option value="yes">Yes</option>
    <option value="no">No</option>
</select>

<input type="radio" name="showHide" value="yes" data-checkvisibility="target1:yes" />
<input type="radio" name="showHide" value="no" data-checkvisibility="target2:no" />

<div id="target1" style="display:none;">This is Target 1</div>
<div id="target2" style="display:none;">This is Target 2</div>

Example Callback Usage

You can specify custom actions when an element is shown or hidden by passing callback functions.

onShow Callback Example:

onShow: (element) => {
    console.log('Element is shown:', element);
}

onHide Callback Example:

onHide: (element) => {
    console.log('Element is hidden:', element);
}

Methods

new AutoShowHideFields(options) This is the main class that initializes the module.

Options:
  • selector (string, default: "[data-checkvisibility]"): The selector for elements with the data-checkvisibility attribute.
  • duration (number, default: 0): The duration (in milliseconds) for transitions when elements are shown/hidden.
  • autoTriggerChange (boolean, default: true): Whether to automatically trigger the change event to initialize visibility.
  • onShow (function, default: null): Callback function when an element is shown.
  • onHide (function, default: null): Callback function when an element is hidden.

License

This project is licensed under the MIT License.

Author

Developed by codevadi, Contributions and feedback are welcome!

Gmail : [email protected] Website : prestashopexperts