【发布时间】:2011-06-03 16:44:36
【问题描述】:
我试图显示一个由 a 标签点击触发的隐藏 div:
按钮代码如下所示:
<a href="#" onclick="return false;" class="viewMoreProducts">View Related Products</a>
这是我单击按钮时的 jquery:
// Show Hidden Product Boxes on Expand - More Products and More Link
$(".viewMoreProducts").click(function() {
$(this).parent().parent().parent().find(".moreProductsBox:first").slideToggle(300, function (){
if ($(this).parent().find(".moreProductsBox").is(":visible")){
$(this).find(":input").addClass("visibleCounter");
}
if ($(this).parent().find(".moreProductsBox").is(":hidden")){
$(this).find(":input").removeClass("visibleCounter");
}
});
});
我可以让隐藏 div 的切换工作正常,但我还想更改链接上的文本以在 div 显示时更改,然后显示它具有“隐藏相关产品”并显示不同的图标崩溃。然后,如果我折叠它,它会返回阅读查看相关产品并带有加号图标。
有什么方法可以将它添加到我已经拥有的 jquery 中?
这听起来很直截了当,但让我四处奔波。
谢谢
【问题讨论】:
标签: jquery html hyperlink toggle