In your code, the first time you click the button, popover is only triggered for init, so until the second click you see the effect,
I'm not sure if you used the popover version. As the resource I found, they also use jquery.
https://github.com/klaas4/jQuery.popover/blob/master/demo.html
First, you can start popover first, and then click on the button with any button you want. First approach, bind the popover directly to the button
$(function(){ $("[name=usernameL]").popover({trigger: 'click'}); });
Second appoach, associate the popover with the contents of the div and show the popup using the button
$("#divcontent").popover({trigger: 'click'}); $("[name=usernameL]").click(function(){$("#divcontent").trigger('click')});
source share