我有一個鏈接,用戶選擇,顯示一個段落,一旦他們選擇它,我希望它顯示不同的圖像,最初圖像將是一個加號(+)的符號,以可視化的方式通知它可以被點擊來滑動內容以看到,一旦它被點擊,我希望它變成一個減號( - ),所以他們可以點擊,它會滑回備份並消失。根據鏈接狀態顯示不同的圖像
我得到了slideToggle下來,我只需要根據鏈接的當前狀態(顯示或隱藏)插入圖像文件路徑。
例jQuery和HTML:
<a href="#" class="slide-down">Click <img src="insert-filename-of-image"></a>
$(document).ready(function() {
$('.slide-down').click(function() {
$(".content-to-slide-down").slideToggle(100);
});
});
所有我需要做的就是把適當的圖像文件名,路徑中的<img src="">
任何幫助表示讚賞。
感謝亨裏克,種了noobie,你可以在切換()函數部分填寫,以幫助我更好地理解。 – Brad 2010-07-07 19:09:24
我在切換功能中添加了一些示例。就我個人而言,我認爲這比比較上面提到的Mikael這樣的url字符串更快更清潔。 – 2010-07-07 19:17:38
同意Henrik - Mikael的建議不是最佳 – HurnsMobile 2010-07-07 19:18:51