Nick Ginanto
Nick Ginanto

Reputation: 32190

closing bootstrap popover doesn't work

I have the following js code

$('#myelemt').popover({placement: 'right', title: 'What is this',
    content: 'content content content content content content content content content content content ', trigger: 'manual', html: 'true', container: '.wrap'});

$('#myelemt').click(function(e) {
    $('#myelemt').popover('show');
    $('.popover-title').append('<button type="button" class="close close_help">&times;</button>');
    e.stopPropagation();
});

$('.close_help').click(function(e) {

    $(this).parents('#myelemt').popover('hide');
    e.preventDefault();
});

I want to close the popover when the .close_help is clicked, but it doesn't work. I tried several ways of getting to the parent .popover to hide it but it doesn't work. The above is one of those ways

here is a jsfiddle simulation

Upvotes: 0

Views: 591

Answers (1)

vinothini
vinothini

Reputation: 2604

Please have a look at jsfiddle

I did changes in the below line only

$('.popover-title').append('<button type="button" class="close close_help" onclick="$(&quot;#myelemt&quot;).popover(&quot;hide&quot;);">&times;</button>');

Let me know your comments.

Upvotes: 2

Related Questions