另一个DEMO ...在弹出框内带有链接,如问题中的评论中所述。
http://jsfiddle.net/weuWk/1126/
相关代码..
var img = '<a href="https://si0.twimg.com/a/1339639284/images/three_circles/twitter-bird-white-on-blue.png" target="_blank" id="1">TEST</a>';
$("#blob").popover({
trigger: "manual",
content: img
}).on("click", function(e) {
e.preventDefault();
}).on("mouseenter", function() {
$(this).popover("show");
$(this).siblings(".popover").on("mouseleave", function() {
$(this).hide();
});
}).on("mouseleave", function() {
var _this = this;
setTimeout(function() {
if (!$(".popover:hover").length) {
$(_this).popover("hide")
}
}, 100);
});
$(document).on('click', '#1',function(){
console.log("CLicked");
});
考虑到 bootrstrap 弹出框进行更新。如果它仍然不适合您,请更好地显示 HTML,甚至更好地在 jsfiddle 上显示您的问题 DEMO。
http://jsfiddle.net/AFffL/547/
<a class="popup-marker btn" data-content="Click outside the popover to close it." data-original-title="Popover A" href="youtube.com" target="_blank">Click me (A)</a>
jQuery(function() {
$('.popup-marker').popover().on('click', function(e) {
// if any other popovers are visible, hide them
var a='Hi!';
var clicked='yes';
console.log(a+clicked);
});
});
_---------------------------------------------------- ---
您显示的代码确实按照您所说的做......参见演示
http://jsfiddle.net/tymeJV/CE2k5/ (.. 由 tymeJV 在评论中)...
但是,如果链接在运行时由dom manipulation
或加载Ajax
,那么您的代码可能无法正常工作。在这种情况下,请尝试以下代码。
$(document).on('click','#LinkClick1',function(){
var a='Hi!';
var clicked='yes';
console.log(a+clicked);
});
而不是$(document)
你可以Selector for parent
使用#LinkClick1