Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery difference between live() and ready()?

What is the exact difference between live() and ready()?


Edit: found that die() is the opposite of live()

like image 794
powtac Avatar asked Dec 14 '22 01:12

powtac


2 Answers

.ready() lets you register a callback that fires when the DOM is ready - this is similar to using window.onload but fires earlier (and you can register more than one callback).

.live() lets you register a callback to a range of events based on a selector, which continually monitors the DOM and will register itself to new nodes that are added.

like image 194
Greg Avatar answered Dec 24 '22 09:12

Greg


live is used for attaching events to a current selector and all future matching selectors.

ready binds a function to be executed whenever the DOM is ready to be traversed and manipulated

like image 31
brad Avatar answered Dec 24 '22 09:12

brad