![](/img/trans.png)
[英]how to change the image when the hyperlink which is clicked in javascript?
[英]How to change an image when clicked using JavaScript?
我在這里創建了一個滑動圖像查看器。 如您所見,有4個可點擊的小圖像來更改/滑動圖像。 我希望在單擊小圖像或顯示適當的主圖像時,將小圖像更改為該圖像的替代文本http://beta.d-load.org/images/etc/imagev-on.png 。 這樣,用戶可以知道正在顯示哪個主圖像。 誰能看看源代碼並解釋如何做到這一點? 謝謝!
試試下面的代碼!
var src = [];
src['normal'] = "http://beta.d-load.org/images/etc/imagev-norm.png";
src['active'] = "http://beta.d-load.org/images/etc/imagev-over.png";
$(document).ready(function() {
$('a',$('.paging')).click(function() {
$('a',$('.paging')).find('img').attr('src',src['normal']);
$(this).find('img').attr('src',src['active']) ;
});
});
演示 ,您在這里: http : //jsfiddle.net/qTB9g/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.