$("a[rel='view-show-info']").click(function() {
$(this).parent().next('.show-info').slideToggle(70);
var img = $("img", this).attr("src");
if(img == "<?=base_url();?>assets/images/plus.png") // or check the end of the path or similar
$("img", this).attr("src", "/images/minus.png");
else
$("img", this).attr("src", "/images/plus.png");
return false;
});
<a href="#" rel="view-show-info" class="view-more">
<img src="/images/plus.png" alt="expand selection">
</a>
根据用户点击的内容显示加号或减号图像。根据链接状态附加标题以链接(a href)标记
我想为链接添加一个标题,如果图片显示的是minus.png图片,请将title设置为title =“合约选择”,如果显示的是plus.png图片,则将其设置为title = “扩大选择”
因此链接将是这样的:
minus.png:
<a href="#" rel="view-show-info" class="view-more" title="contract selection">
<img src="/images/minus.png" alt="contract selection">
</a>
plus.png
<a href="#" rel="view-show-info" class="view-more" title="expand selection">
<img src="/images/plus.png" alt="expand selection">
</a>
我想我必须使用append函数,但是尽我所知,任何帮助表示赞赏。
似乎可以在除IE7以外的任何应用程序中工作。 – Brad 2011-01-14 16:47:09