下面是一个更大项目的一部分(显然),它在 Chrome、Firefox 和 Opera 中运行良好,但 .click() 函数没有被 IE9 或 10 调用。
jQuery('.current img').hover(function() {
var thisElem = jQuery(this);
thisElem.parent().parent().find('.hotspot span:not(.select-image)').remove();
thisElem.parent().parent().find('.hotspot img').parent().find('span.select-image').remove();
jQuery('<span class="zoom-out"></span>').prependTo(thisElem.parent()).click(function() {
z -= .1;
z = Math.max(z, 1);
jQuery(this).parent().find('img').attr('src', '<?php echo $urlPrefix; ?>/zcard-thumbnail-image/photos/<?php echo $modelId; ?>/low/' + i + '/' + (w * z) + '/' + (h * z) + '/file');
});
jQuery('<span class="select-image"></span>').prependTo(thisElem.parent());
jQuery('<span class="zoom-in"></span>').prependTo(thisElem.parent()).click(function() {
z += .1;
z = Math.min(z, 5);
jQuery(this).parent().find('img').attr('src', '<?php echo $urlPrefix; ?>/zcard-thumbnail-image/photos/<?php echo $modelId; ?>/low/' + i + '/' + (w * z) + '/' + (h * z) + '/file');
});
});
据我所知, .click() 没有绑定,因为元素还不存在。如果我改为使用 jQuery(target).prepend(element),然后发出延迟进一步执行的警报,然后 .click() 绑定,一切正常。不幸的是,用 delay() 替换警报不会产生相同的结果。
请问有人有建议吗?