Demo 1 :: Toggling

A lot of sites use toggling for many things on their site. They may use it for navigation, for showing information, or for turning something on or off on a page. What ever it may be, jQuery can handle it. And jQuery makes it very easy to toggle items on a page.

View the HTML code

<p id="toggle">A lot of sites use toggling for many things on their site. They 
may use it for navigation, for showing information, or for turning 
something on or off on a page. What ever it may be, jQuery can 
handle it. And jQuery makes it very easy to toggle items on a page.</p>

View the jQuery code

$(document).ready(function(){
  $('<input type="button" value="Hide the description!" id="toggleButton">').insertAfter('#toggle');
  $('#toggleButton').click(function(){
    $('#toggle').slideToggle();
    
    if($('#toggle').is(':visible')) {
      $(this).val('Hide the description!');
    } else {
     $(this).val('Show the description!');
	}//if/else statement
  });//$('#toggleButton').click(function(){
});//$(document).ready(function(){