开发者

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜