elkun49
elkun49

Reputation: 133

How to select new added elements with jquery selector

I have a selector to select all elements with rel="tooltip" attribute: $("[rel='tooltip']").tooltip(); But when I add new elements dynamically, for example using append() method ,it seems not working. How can I select that new ones ?

Upvotes: 0

Views: 345

Answers (1)

John
John

Reputation: 975

When you call

$("[rel='tooltip']").tooltip()

This initializes the elements currently in the document. You will need to call the function again to initialize new "tooltip" elements.

You can just add the same jquery snippet directly after you've added the new elements to the DOM, or bind and trigger events.

This really depends on how you plan to add the new tools tips to the page dynamically

Upvotes: 2

Related Questions