Hi everybody,

I have a js(using jQuery lib) file where all events and following actions(functions) are written.
For one of such events there is a function that prepends one more similar element from which prepending was called:

$(...).before("<div id='id1'></div>");

so that when I will click to just prepended element one more element should be prepended and so on.

The problem is that when new element is prepended, click event doesn't work on it. jQuery doesn't recognize it, like doesn't see it. How to fix it?

Thnx in advance


$(sel).click(...) attaches functionality only to matching elements that exist when the command is executed.

Use $(sel).live(...) to attach functionality to existing matching elements and any future elements that also match sel.


Thank you very much, Airshow!!! Exactly what I need!)