Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bootstrap popover button click event does not working using jquery

I use the code for bootstrap popover as follows,

<a href="javascript:void(0);" class="btn btn-primary btn-sm" rel="popover"  data-placement="top"
                        data-original-title="<i class='fa fa-fw fa-users'></i> Enter New Investor Group"
                        data-content="<div class='smart-form'><div class='col-sm-10'><label class='input'><input type='text' name='NewInvestor' placeholder='Investor Group Name' id='NewInvestor' /></label></div><div class='col-sm-2'><button id='btntest' class='btn btn-primary btn-sm assignedGroup' type='button' data-target-id='NewInvestor' >ADD</button></div></div><div class='clearfix'></div><br/>"
                        data-html="true">Add</a>

I would like to trigger a event on button click in jquery. Code as follows,

$("#btntest").click(function () {
        alert("You click on button");
    });

JSFiddle

What would be the reason my code is not working?

I will appreciate your help in advanced.

like image 311
sridharnetha Avatar asked May 12 '15 08:05

sridharnetha


1 Answers

Assuming your code renders correctly, try the code below.

$(function(){
   $(document).on('click',"#btntest",function () {
      alert("test button clicked");
   });
});

Edited

Take a look at my JsFiddle and see if it works http://jsfiddle.net/jb5fexp3/

like image 73
Nifal Munzir Avatar answered Sep 20 '22 14:09

Nifal Munzir