Remove jQuery delegated event handler on specific object

后端 未结 3 705
时光说笑
时光说笑 2020-12-19 10:53

I\'ve attached delegated event handlers to a number of elements on the page using a single selector. As the events are triggered for individual elements, I\'d like to turn o

3条回答
  •  情书的邮戳
    2020-12-19 11:05

    Question: Do you have to use the delegated events? LIke LShetty said, it is not possible to remove a delegated event for a single element. You either remove the entire event delegation, or leave it. You could try using a different selector instead like in this example

    $('button').on('click', function(ev) {
        $('#output').append('Clicked! ');
        $(this).off('click');
    });
    
    
    
    
    

提交回复
热议问题