Adding a new dom element, desire to re-bind

After adding a new DOM element after an ajax request, the click event for the newly added element does not work.

I tried to disconnect the binding first, but I am getting an error.

$(".someclass").unbind("click", someEvent); $(".someclass").bind("click", someEvent); 

Am I doing something wrong here? (in theory)?

+1
source share
1 answer

Use live () instead of bind ().

 $('.someclass').live('click', someEvent) 
+1
source

Source: https://habr.com/ru/post/1309838/


All Articles