0
我试图做一个简单的画廊,并不能找出什么是我的jQuery语法错误。jQuery语法帮助 - 幻灯片画廊代码
当用户点击缩略图(前三个列表项之一)时,我想clone()
图片和标题,并将其粘贴到li.expand
(全尺寸图片)。
我的jQuery函数的前两行正在工作(即“选择”类),但最后两行似乎没有做任何事情。我使用$(this)
错误吗?
HTML
<ul class="gallery2">
<li>
<img src="img/1.jpg" />
<p>Caption 1</p>
</li>
<li>
<img src="img/2.jpg" />
<p>Caption 2</p>
</li>
<li>
<img src="img/3.jpg" />
<p>Caption 3</p>
</li>
<li class="expand">
<!-- This space will be filled with whatever thumbnail is selected -->
</li>
</ul>
的jQuery
$(".gallery2 li").click(function() {
$(".gallery2 li").removeClass("selected");
$(this).addClass("selected");
$(".gallery2 li.expand").html().remove();
$(this).html().clone().appendTo(".gallery2 li.expand");
});
很好。我不知道html()返回一个字符串,谢谢! – 2012-03-16 11:49:46