我目前有一个带有按钮的引导弹出窗口。仅当鼠标悬停在表格上时才会显示弹出框tr
。
我想要做的是能够访问该行的元素,这可能吗?
弹出框代码:
$('.popup').popover(
{
placement: 'top',
trigger: 'manual',
delay: { show: 350, hide: 100 },
html: true,
content: $('#shortcuts').html(),
title: "Quick Tasks"
}
).parent().delegate('#quickDeleteBtn', 'click', function() {
alert($(this).closest('tr').children('td').text()); // ???
});
var timer,
popover_parent;
function hidePopover(elem) {
$(elem).popover('hide');
}
$('.popup').hover(
function() {
var self = this;
clearTimeout(timer);
$('.popover').hide(); //Hide any open popovers on other elements.
popover_parent = self
//$('.popup').attr("data-content","WOOHOOOO!");
$(self).popover('show');
},
function() {
var self = this;
timer = setTimeout(function(){hidePopover(self)},250);
});
$(document).on({
mouseenter: function() {
clearTimeout(timer);
},
mouseleave: function() {
var self = this;
timer = setTimeout(function(){hidePopover(popover_parent)},250);
}
}, '.popover');
HTML:
<div class="hide" id="shortcuts">
<a href="javascript:void(0);" id="quickDeleteBtn" class="btn btn-danger">Delete</a>
</div>
在行上实现popover的javascript:
rows += '<tr class="popup datarow" rel="popover">';
有谁知道我在这里做错了什么以及我应该如何访问tr
我悬停的子元素?
JSFiddle:http: //jsfiddle.net/C5BjY/8/