<a href="#" data-studentId="01" data-toggle="popover">Student1</a>
<a href="#" data-studentId="02" data-toggle="popover">Student2</a>
<a href="#" data-studentId="03" data-toggle="popover">Student3</a>
JS:
$(function () {
$("a").hover(function(){
var e = $(this);
var studentId = e.attr('data-studentId');
$.ajax({
url: 'http://www.***',
type: 'get',
data:{"studentId":studentId},
dataType: 'jsonp',
success: function(msg){//msg: {name: "Lisa",gender: "female"}
var content = '<div>' + msg.name + '</div>' + '<div>' + msg.gender + '</div>';
e.popover({
html: true,
trigger: 'hover',
placement: 'bottom',
container: 'body',
content: content,
delay: { "show": 500, "hide": 200 }
})
}
})
})
})
当我第一次悬停$(&#34; a&#34;)时,弹出窗口不会显示。从第2次开始,弹出窗口出现。我搜索了SO的时间,但没有找到合适的解决方案。我想从第一次看到popover节目。请帮助我。非常感谢!