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
fadeToggle
Moderator: General Moderators
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: fadeToggle
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>
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering