Disable and enable jQuery context menu

后端 未结 2 546
面向向阳花
面向向阳花 2021-01-15 03:56

I use

$(\'#test\').unbind(\'click\');

to remove the click event on the #test item. How do I make the item clickable again?

Actual

2条回答
  •  孤城傲影
    2021-01-15 04:35

    Take a look at this question Rebind DOM Event with jQuery

    Josiah's solution is preferable but if you really wanted to unbind the click event entirely I believe you could do this:

    var storedClick = $('#test').data('events').click[0].handler;
    $('#test').unbind('click');
    $('#test').bind('click', storedClick);
    

    Remember that data('events').click is an array so you would need to store the handler for every member of the array.

提交回复
热议问题