Jquery 'click' not firing when icon is on button

前端 未结 3 1261
Happy的楠姐
Happy的楠姐 2021-01-19 14:17

I use Bootstrap and jQuery. I have three buttons, each with an icon in it. When I bind an click-event to a button, it works when I cli

相关标签:
3条回答
  • 2021-01-19 14:42

    Update your css with the following. I'm assuming you don't need mouse events on your icon.

    .icon-eye-open {
    
        pointer-events:none;
    }
    

    MDN Information regarding pointer-events

    0 讨论(0)
  • 2021-01-19 14:48

    Use the following syntax for .on()

    $(document).on('click','btn_change_status', function(e) {
       //write your code here
    });
    
    0 讨论(0)
  • 2021-01-19 14:53

    You need a different syntax, as per the documentation:

    $('body').on('click', 'button.btn_change_status', function(e) {
       alert(e.target.id);
       return false;
    });
    
    0 讨论(0)
提交回复
热议问题