Hide/Show text using jQuery


/ Published in: jQuery
Save to your folder(s)

A little snippet that I use to hide or show text using jquery


Copy this code and paste it in your HTML
  1. <div id="extra">This is could be a hidden form</div>
  2. <input type="checkbox" id="checkme" />
  3. <label>Click me</label>
  4.  
  5. <script>
  6. $(document).ready(function () {
  7.  
  8. //Hide div w/id extra
  9. $("#extra").css("display", "none");
  10.  
  11. // Add onclick handler to checkbox w/id checkme
  12. $("#checkme").click(function () {
  13.  
  14. // If checked
  15. if ($("#checkme").is(":checked")) {
  16. //show the hidden div
  17. $("#extra").show("fast");
  18. } else {
  19. //otherwise, hide it
  20. $("#extra").hide("fast");
  21. }
  22. });
  23.  
  24. });
  25. </script>

URL: http://jsfiddle.net/TwistedEinstein/eGfgC/1/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.