私は単純なギャラリーを作ろうとしていて、私のjQuery構文の何が間違っているのか分かりません。jQueryの構文ヘルプ - フィルムストリップギャラリーコード
サムネイル(最初の3つのリストアイテムの1つ)をクリックすると、clone()
の画像とキャプションが表示され、li.expand
(フルサイズの画像)に貼り付けられます。
私のjQuery関数の最初の2行は動作していますが、最後の2行は何もしていないようです。 $(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()が文字列を返したことを知りませんでした。ありがとう! –