当点击收藏的底部链接时,我会更改顶部链接上的文本。jquery如何切换花药div上的文本更改
当前顶部链接上的文本仅在顶部链接被点击时发生变化。下面
是我的jQuery
$(document).ready(function() {
// choose text for the show/hide link - can contain HTML (e.g. an image)
var showText = 'Hide Information';
var hideText = 'Show Information';
// initialise the visibility check
var is_visible = false;
// append show/hide links to the element directly preceding the element with a class of "toggle"
$('.collapseLink').append('<span class="dottedBot">' + showText + '</span>');
// hide all of the elements with a class of 'toggle'
$('.revealBoxContents').show();
// capture clicks on the toggle links
$('a.collapseLink').click(function() {
// switch visibility
is_visible = !is_visible;
// change the link depending on whether the element is shown or hidden
$(this).html((!is_visible) ? showText : hideText);
// toggle the display - uncomment the next line for a basic "accordion" style
//$('.toggle').hide();$('a.toggleLink').html(showText);
$(this).parent().next('.revealBoxContents').slideToggle('slow');
// return false so any link destination is not followed
return false;
});
// toggle the bottom link
$('.collapseLink').click(function() {
$(this).parents('.revealBoxContents').stop(true, true).slideToggle('slow');
});
});
这里是URL
http://satbulsara.com/NSJ-local/eqs1.htm
很想知道如何做到这一点。
感谢,
周六
冷静,这是几乎是它但如何将这种变化回来时,其再次点击 – sat 2011-05-24 16:23:53
基本上是一样的。通过JavaScript中的每个事件,您需要确定需要触发的事件或事件。如果标签上有两个事件可能,那么您只需来回切换。如果有的话,你必须确定条件并使用条件逻辑。如果需要更改回以前的值,则必须将原始值存储在变量中,然后再更改。如果你只是改变一个不同的文本,它是相同的方法,但不同的功能或功能分支。合理? – 2011-05-24 17:19:41