chrisdavies / tlite

A tiny tooltip utility library.
https://chrisdavies.github.io/tlite/
90 stars 19 forks source link

tooltips for elements created by javascript? #6

Closed jedierikb closed 7 years ago

jedierikb commented 7 years ago

Can I add tooltips to elements I've created and added via javascript? Could you provide an example?

chrisdavies commented 7 years ago

Yup. It uses event delegation, so dynamic elements should work. You can try it out by throwing this code into an HTML page where you've got tlite's JS and CSS included:

tlite(function (el) { return el.classList.contains('foo'); });

document.body.innerHTML = '<button class="foo" title="Hi">Hover Here</button>';