我正试着制作一个jQuery图像转换器。这是我的HTML结构:
<div id="modal">
<div id="colors">
<ul class="product-image-thumbs">
<li>
<a href="#">
<img src="thumb-0.jpg" id="thumb-0" class="gallery-image">
</a>
</li>
<li>
<a href="#">
<img src="thumb-1.jpg" id="thumb-1" class="gallery-image">
</a>
</li>
<li>
<a href="#">
<img src="thumb-2.jpg" id="thumb-2" class="gallery-image">
</a>
</li>
</ul>
</div>
<div class="photo">
<img src="current_img" id="1">
</div>
</div>这是我的jQuery:
jQuery(document).ready(function(){
jQuery(".gallery-image").click(function(){
$(".photo").prop("src", jQuery(this).prop("src"));
return false;
});
});当我尝试代码时,我会得到以下错误消息:
Uncaught TypeError: Cannot read property 'prop' of null有人知道密码有什么问题吗?
发布于 2014-09-21 17:29:29
在div中有img标记是这样做的:
$(".photo > img").prop("src", jQuery(this).prop("src"));Working Example
https://stackoverflow.com/questions/25961900
复制相似问题