我有一张图片列表。单击一个时,我希望它突出显示该图像并将其他图像设置为正常。这可以通过jQuery切换完成吗?
答案 0 :(得分:3)
尝试这样的事情:
$('img').click(function() {
$(".highlight").removeClass("highlight"); //remove the highlight css class from anything that has it
$(this).addClass("highlight"); //add the highlight css class to the image that was clicked.
});