toggle in jquery code example

Example 1: toggle text jquery

$("button").click(function(){
  $(this).text($(this).text() == 'Show' ? 'Close' : 'Show');
});

Example 2: jquery toggle class

$( "#foo" ).toggleClass( 'className', addOrRemoveOptional );

Example 3: jquery toggle show hide

$( "#clickme" ).click(function() {
  $( "#book" ).toggle( "slow", function() {
    // Animation complete.
  });
});

Example 4: hide show toggle

$(document).ready(function() {
    $("#btnshow").click(function() {
      $("#imgshow").slideToggle();
    });
  })

Tags:

Html Example