Return to Snippet

Revision: 18545
at October 1, 2009 19:40 by mikemetcalf


Updated Code
$('.toggle').click(function() {
	var $this = $(this); 
	if ('[+]' == $this.text( )) { 
	     $this.text('[-]').parent( ).find('.hidden').show( ); 
	} 
	else { 
	     $this.text('[+]').parent( ).find('.hidden').hide( ); 
	}
});

Revision: 18544
at October 1, 2009 19:39 by mikemetcalf


Updated Code
$('.toggle').click(function() {
	var $this = $(this); 
	if ('[+]' == $this.text( )) { 
	     $this.text('[−]').parent( ).find('.hidden').show( ); 
	} 
	else { 
	     $this.text('[+]').parent( ).find('.hidden').hide( ); 
	}
});

Revision: 18543
at October 1, 2009 19:36 by mikemetcalf


Updated Code
$('.toggle').click(function() {
	var $this = $(this); 
	if ('[+]' == $this.text( )) { 
	     $this.text('[�]').parent( ).find('.hidden').show( ); 
	} 
	else { 
	     $this.text('[+]').parent( ).find('.hidden').hide( ); 
	}
});

Revision: 18542
at October 1, 2009 19:36 by mikemetcalf


Updated Code
$('.toggle').click(function() {
	var $this = $(this); 
	if ('[+]' == $this.text( )) { 
	     $this.text('[�]').parent( ).find('.hidden').show( ); 
	} 
	else { 
	     $this.text('[+]').parent( ).find('.hidden').hide( ); 
	}
});

Revision: 18541
at October 1, 2009 19:34 by mikemetcalf


Initial Code
$('.toggle').click(function() {
	var $this = $(this); 
	if ('[+]' == $this.text( )) { 
	     $this.text('[−]').parent( ).find('.hidden').show( ); 
	} 
	else { 
	     $this.text('[+]').parent( ).find('.hidden').hide( ); 
	}
});

Initial URL

                                

Initial Description
Example markup:

<p>This is the first part of the text <a class="toggle">[+]</a><span>this part is hidden until clicking the toggle link.</span></p>

The script will show and hide text when the toggle link is clicked. It also swaps out the + with the − when the the text is toggled.

Initial Title
Toggle more text

Initial Tags
jquery, text

Initial Language
jQuery