不知道为什么,但我无法找到解决方案。我有3个链接,点击后我想使用jQuery更改下面的图像。有谁知道一个非常简单的脚本,告诉我这可能如何工作?提前谢谢。
答案 0 :(得分:1)
<强> HTML 强>
<img id="change" src="http://www.nvidia.in/docs/CP/26740/thumbs_googleearth.jpg" />
<br>
<a href="javascript:void(0)" class="gog" alt="http://www.nvidia.in/docs/CP/26740/thumbs_googleearth.jpg" >earth</a>
<br>
<a href="javascript:void(0)" class="gog" alt="http://www.techbusy.org/wp-content/uploads/2011/10/block-websites-google-search-100x100.jpg" >block</a>
<br>
<a href="javascript:void(0)" class="gog" alt="http://www.bishanindia.com/wp-content/uploads/2011/10/google-plus-l-100x100.jpg" >google plus</a>
<强> JQUERY 强>
$(document).ready(function(){
$(".gog").click(function(){
$("#change").attr("src",$(this).attr("alt"));
})
})
Jsfiddle墨水供参考