![](/img/trans.png)
[英]Get the innerText of a p tag when clicking on a button sitting next to it (no Jquery)
[英]Get the context when clicking a button in a qtip jquery
这是一个普遍的问题。 我有下面的代码, #datatable
是(你猜对了)一个datatable
$("#datatable").on(
"mouseenter",
"td",
function(event) {
$(this).qtip(
{
content:"<button>Test</button>",
position: {
my: 'bottom left',
at: 'center right',
adjust : {
method: "shift"
},
viewport: $('#datatable')
},
show: {
event: event.type,
ready: true
},
hide: {
fixed: true
}
},
event
);
}
);
当我单击qTip2
工具提示中的按钮时,我希望能够使用$(this)
所有优点(例如,获取列名和/或单元格的值)。
jsFiddle 在这里 :当您单击Test
按钮时,如何显示带有列名的警报?
您可以为按钮提供一个类,并在呈现工具提示后单击触发。
不需要this
关键字:
content:"<button class='my-btn'>Test</button>",
/*...*/
events: {
render: function(e, api){
$(".my-btn").on("click", function(){
alert(api.target[0].innerText);
});
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.