$("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