<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>
上面表示一个类,其中存储了两个图像。它的布局使得每当我点击两个图像中的以太之一时,它都会做出反应。
$(".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
并想导入另一张图像,该怎么做?