javascript - click event of parent element not working
typecho
typecho 2017-06-26 10:50:11
0
2
766

The cloud-zoom plug-in I use. The internal structure is as follows

  • 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的事件触发。
    typecho
    typecho

    Following the voice in heart.

    reply all (2)
    过去多啦不再A梦

    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 falseDon’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 future

    For details, please check
    http://www.jb51.net/article/4...

      伊谢尔伦

      If you don’t want to jump, useNo, it will be fine. If youreturn falsein the event, the event will be invalid.

        Latest Downloads
        More>
        Web Effects
        Website Source Code
        Website Materials
        Front End Template
        About us Disclaimer Sitemap
        php.cn:Public welfare online PHP training,Help PHP learners grow quickly!