Bootstrap Popover中按钮上的Click和Alert问题

Suf*_*fii 3 javascript jquery twitter-bootstrap twitter-bootstrap-3

你能看看这个演示,让我知道为什么

$(".onealert").on("click",function(){
    alert("You clicked on A");
});
Run Code Online (Sandbox Code Playgroud)

不起作用?

这是我的代码:

<div class="the-box">
    <div class="pull-right btn-group btn-group-sm" id="downloadSelect">
        <button type="button" class="btn btn-default">1</button> 
        <button href="#" class="trigger btn btn-default">2</button> 
        <button type="button" class="btn btn-default">3</button>
    </div>
    <div class="head hide">Alphabet Select</div>
    <div class="content hide">
        <div class="form-group">
            <div class="btn-group btn-group-sm">
                <button type="button" id="1Download" class="btn btn-default onealert">A</button>
                <button type="button" id="2Download" class="btn btn-default">B</button>
                <button type="button" id="3Download" class="btn btn-default">C</button>
            </div>
        </div>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

我也没有收到任何错误消息!

谢谢

ade*_*neo 8

那是因为Bootstrap为它出现的小对话框构建了新的标记,只使用隐藏标记作为模板,这意味着它是添加事件处理程序时不存在的动态内容,并且您需要一个委托的处理程序

$('.the-box').on("click", ".onealert", function(){
    alert("You clicked on A");
});
Run Code Online (Sandbox Code Playgroud)

小提琴