I found this helpful jsfiddle on adding tooltips with jQuery.
How could I get the same results but with dynamically created elements?
Without any plugins, if thtas possible.
http://jsfiddle.net/UQTY2/29/
Depending on which options a user ticks, my div will display one of three coloured circles to show the importance of a task. Can I add a tooltip to the circles in a manner such as this?
jQuery(function() {
jQuery( '.veryImportant' ).tooltip();
});
You just add the tooltip how you normally would, only make sure that you are calling .tooltip()
AFTER the element has been added to the page. Based on your code, it seems you're trying to add it immediately, and if that element doesn't exist, it will never get it.
Simple sample:
<div id='test'>im a div</div>
$("#test").append("<span id='spantest'>hey</span>");
$("#spantest").tooltip(); //works fine, since the element exists at time of call
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With