Is jquery bind()
deprecated or it can be used safely?
I see a lot of comments about bind() being deprecated in comments and answers across SO like: Jque
No it's not, that are a difference between .on
and .bind
basically .bind
is only called directly from a element i.e. $("#elem").bind(...)
, so the element must exist by the time the bind function is called. And .on
can be "bind" on document i. e. $(document).on("click",".class",funcion(){...});
, so if you add an element dynamically by using .append
or other way, the event will be valid.