Instead of doing

$(selector).click(function(){});
$(selector).bind('click', function(){});

use

$(selector).live('click', function(){});


On Jun 11, 12:04 pm, Sasha <sasha.akh...@gmail.com> wrote:
> Hi everyone.  I've run across what must be a common problem:
>
> When my page loads, I bind every element of a certain class to some
> function (via click, focus, or whatever).  Then I dynamically create
> another element with that same class on the page, and the new element
> lacks the binding.
>
> Is there a nice shorthand way of saying "bind this function to this
> class/id/selector always and forever," no matter whether matching
> elements are created or destroyed?  I'd rather not have to worry about
> re-binding my elements every time I create new ones.
>
> Thanks! SA

Reply via email to