我有以下的jQuery为什么我的函数在jQuery中被调用两次?
$('img[title*=\"Show\"]').click(function() {
//$e.preventDefault();
var position = $('img[title*=\"Show\"]').parent().position();
$('#popover').css('top', position.top + $('img[title*=\"Show\"]').parent().height() + 150);
console.log(position);
$('#popover').fadeToggle('fast');
if ($('img[title*=\"Show\"]').hasClass('active')) {
$(this).removeClass('active');
} else {
$('img[title*=\"Show\"]').addClass('active');
}
});
我有标题两个图像“显示选项”。出于某种原因,每当我点击任何这些图像时,它都会被打印TWICE。当我只有一个图像时,它只会被打印一次。为什么是这样?