Page 1 of 1

fadeToggle

Posted: Sat Aug 25, 2012 10:58 am
by YoussefSiblini
Hi,
I am using the fadeToggle to hide and show a div, it is working fine but I want the text inside another div to be changed depending in the div if it is hidden or visible.

Here is the jsfiddle link to my code:

http://jsfiddle.net/Banzay/kUGRP/


Many thanks,


Jo

Re: fadeToggle

Posted: Sun Sep 02, 2012 10:47 am
by social_experiment
This snippet does what you have in mind; just change it to match your HTML

Code: Select all

$(document).ready(function(){
 $('div#clicker').click(function(){
	$('div#box').fadeToggle("slow", "linear")
	
	if ($('div#clicker').text() == 'Hide' ) {
		$('div#clicker').text("Show");
	}
	else {
		$('div#clicker').text('Hide');
	}
 });
});

// my html
// <div id="clicker">Hide</div>
// <div id="box" class="hideBox" >Hide this content.</div>