Git Product home page Git Product logo

showhide.js's Introduction

#showhide.js#

showhide.js is a tiny jQuery plugin that shows, hides and focuses form inputs based upon the value of other form inputs. This makes it just a bit easier to create clean questionnaires on websites.

##Example#

Take a look at the contact form on the Deft, Digital Engineering Company website - elements become visible and invisible dynamically, based on user input.

##Usage#

###Set-up

  • Include jQuery,
  • Include showhide.js or showhide.min.js:
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/showhide.min.js"></script>

####Show/Hide Mark any element you want to show/hide dynamically with the data-show attribute, and set the content of data-show to a jQuery selector targeting the element, e.g.

<label><input type="checkbox" id="showTheDiv" /> Show the div?</label>
<div data-show="#showTheDiv">
	The div is visible!
</div>

The div will only be visible when the checkbox is checked. You can bind data-show to work with radio-buttons too.

Other common binding expressions:

  • data-show=".magic"
  • data-show="#elem1,#elem2,.setOfElements"

##Focus You can also cause elements to automatically obtain focus once checkboxes and radiobuttons are checked. Simply apply data-focus="#elemid" (or ".class") to the appropriate element.

##License/Contrib Licensed under the Apache 2 License.

Contributions and Bug-fixes are always welcome.

showhide.js's People

Contributors

capnfabs avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.