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