Search code examples
jquerytwitter-bootstraptwitter-bootstrap-3popover

how to use 'show' and 'placement' and other attributes in bootstrap 3 popover altogether?


I have some input fields and a link in my html. I want to pop a popover on the link when any of the input fields are clicked. The codes are given below :

$('.name').on('click', function(){
   $('[data-toggle="popover"]').popover('show');    
});

I get the popover, but I need to define placements and other attributes. I tried in the following way, but failed

$('.name').on('click', function(){
    $('[data-toggle="popover"]').popover('show',{
        placement : 'top'
    }); 
});

Any help is appreciated.


Solution

  • You could use the following:

    $('.name').on('click', function () {
        $('[data-toggle="popover"]').popover({
            placement : 'top',
            content : 'I am a popover!'
        }).popover('show');
    });
    

    Example Here