javascript – 关闭它后,Popover不会在首次点击时显示
作者:互联网
你能否看一下This Demo,让我知道为什么弹出窗口在关闭它后通过.close按钮不能正常工作?
$("#pop-One").popover({
placement: 'right',
html: 'true',
title : '<span class="text-info" style=""><strong>Model Type</strong></span>'+
'<button type="button" class="btn btn-default close" onclick="$("#pop-One").popover("hide");">×</button>',
content : '<p class="popup" style="color:#323232;"> \Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry standard dummy text ever since the 1500s,</p>'
});
@import 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css';
@import 'https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css';
body{padding:20px;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<div class="container">
<button type="button" class="btn btn-default" id="pop-One" data-toggle="popover"><i class="fa fa-question"></i></button>
</div>
出于什么原因?!关闭按钮在这里不起作用!所以请检查演示页面以查看完整的功能
我已经看过this Post但这是一种不同的方法
解决方法:
不知道这是最好的解决方案,但它正在发挥作用
$("#pop-One").popover({
placement: 'right',
html: 'true',
title : '<span class="text-info" style=""><strong>Model Type</strong></span>'+
'<button type="button" class="btn btn-default close"\
onclick="$("#pop-One").popover("hide");">×</button>',
content : '<p class="popup" style="color:#323232;"> \Lorem Ipsum is simply dummy\ text of the printing and typesetting industry. Lorem Ipsum has been the industry standard\ dummy text ever since the 1500s,</p>'
}).on('shown.bs.popover', function() {
var popup = $(this);
$(this).parent().find("div.popover .close").click(function() {
popup.click();
});
});
标签:jquery,javascript,twitter-bootstrap-3,bootstrap-popover 来源: https://codeday.me/bug/20190702/1357346.html