Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • "Bind to all links inside #whatever, even new ones created later." Isn't that exactly what .live() does? Also, this seems to contradict with the other answers which say that it only has the functionality of .click(), and therefore doesn't apply to future events.
    – Ben G
    Commented Feb 3, 2012 at 1:34
  • 3
    @babonk - This doesn't contradict the other answers, because as Interrobang said in the first paragraph .on() can do what .click() does and do what .bind() and .live() do - it depends what parameters you call it with. (Some other answers mentioned this too.) Note though that "Bind to all links inside #whatever" is not what .live() does, it's what .delegate() does. .live() binds to all inside document rather than letting you specify the container. Note also .live() is deprecated from jQuery 1.7 onwards.
    – nnnnnn
    Commented Feb 3, 2012 at 1:53
  • +1 for delegated events: "By picking an element that is guaranteed to be present at the time the delegated event handler is attached, you can use delegated events to avoid the need to frequently attach and remove event handlers." api.jquery.com/on
    – jimasp
    Commented May 23, 2014 at 9:13