<div class="leftThumbNail">
<img id = "img1" src="img/thumb/image1.jpg" class = "image1Position" alt="Image 1">
<img id = "img2" src="img/thumb/image2.jpg" class = "image2Position" alt="Image 2" >
</div>
上記は、2 つのイメージが格納されているクラスを表しています。2 つの画像のいずれかをクリックすると反応するようにレイアウトされています。
$(".leftThumbNail").on("click", function(){
var img = $(this).find("img"), // select images inside thumbnail,but which one?
alert(this.id); //prints empty for some reason, I want to have it print the one I clicked on within the class such that I can import a specific image after it is clicked.
});
クリックしたクラス内のどの画像を特定するにはどうすればよいですか? をクリックしてimg1
、別の画像をインポートしたいとします。