The cloud-zoom plug-in I use. The internal structure is as follows
<li title="红色">
<a href="images/bag-img_03.png" class='cloud-zoom-gallery' title='Red' rel="useZoom: 'zoom1', smallImage: 'images/bag-img_03.png' ">
<img src="images/bag-img_03.png" alt="" mid="images/bag-img_03.png" big="images/bag-img_03.png" />
</a>
</li>
a标签插件里面有个点击事件
if($(this).is('.cloud-zoom-gallery')) {
opts = $.extend({}, c, d);
$(this).data('relOpts', opts);
$(this).bind('click', $(this), function(a) {
var b = a.data.data('relOpts');
$('#' + b.useZoom).data('zoom').destroy();
$('#' + b.useZoom).attr('href', a.data.attr('href'));
$('#' + b.useZoom + ' img').attr('src', a.data.data('relOpts').smallImage);
$('#' + a.data.data('relOpts').useZoom).CloudZoom();
return false
})
然后我写的li的事件就失效了。 上面也没阻止这个冒泡事件啊。我把return false去掉就可以了。但是A标签会造成页面的跳转。我又把href改成了别的属性、这样会不会某些地方出错。
或者有没有别的方法可以让li的事件触发。
To prevent the default event of a tag, you can use event.preventdefault()
http://www.w3school.com.cn/js...
An article is written like the picture above
return false
Don’t use it casually, write whatever you want to prevent, and don’t let bad habits make you step on your own mistakes in the futureFor details, please check
http://www.jb51.net/article/4...
If you don’t want to jump, use
<a href="javascript:"></a>
No, it will be fine. If youreturn false
in the event, the event will be invalid.