Get text to change in the link when toggle is activated
Hi all I would like to change the text from Hide information to Show information
when toggling the top link of the accordion I am making.
Also at the bottom of the accordion there is a link inside the element I am slide toggling, when this link is clicked I would like to change the text on the top link only and hide this one as it is currently doing.
here is my jquery
$(document).ready(function(){
//On Click
$('.collapseLink').click(function(){
$(this).parent().next(".revealBoxContents").stop(true, t开发者_开发问答rue).slideToggle('slow');
});
$('.collapseLink').click(function(){
$(this).parents('.revealBoxContents').stop(true, true).slideToggle('slow');
});
});
and here is the URL
http://satbulsara.com/NSJ-local/eqs1.htm
Thanks,
Sat
How about using a callback function? With the selector element :visible you can detect what the current state of your slide element is and display the corresponding text.
Something like this:
$('.collapseLink').click(function(){
$(this).parent().next(".revealBoxContents").stop(true, true)
.slideToggle('slow', function(){
var txt = ($('#yourelement').is(':visible')) ? 'hide' : 'show';
$('#togglelink').html(txt);
})
});
...how to format the code?
精彩评论