user1896653 user1896653 - 2 months ago 23x
CSS Question

How to put close button at jquery tooltip

I've used this tooltip at my webpage. Now, I want to put a "close button" in the tooltip, so if user click on that button, the tooltip will be closed(Though that tooltip close automatically after certain of time but I need to add close button feature too). This is my tooltip:

I need when user click on the close button, the tooltip will be closed.

I put my testing code at jsfiddle.

So, basically I hope, my code should be like this:

$('.tooltipster-content').on('click', '.close', function() {

But, this code isn't working at my webpage.


The reason it is not working is because the event that you are delegating to in your fiddle is not present on the page when you're binding the event. Try the following:

$(document).on('click', '.close', function() {

In addition, you were missing the . on the front of the $('.tooltipster-base') jQuery selector within your bound click callback.