作为标题,我刚刚写了下面的代码......这是创建弹出式div的好方法吗?抱歉我的英语不好。
$("#story-comments-text").mouseenter(function()
{
var popupdiv="<div id='comments-popup'></div>";
$(this).append(popupdiv);
$.post()
{
//post request for popupdiv
}
return false;
}).mouseleave(function(){
$("#comments-popup").remove();
});
答案 0 :(得分:1)
$("#story-comments-text").mouseenter(function(){
var popupdiv = "<div id='comments-popup'></div>",
that = this; // that is reference of #story-comments-text
$.post('url', data, function(data) { // just a demo request, you will configure it
if(data) {
popupdiv.html(res); // make process as you want
that.append(popupdiv);
}
}, 'json');
}).mouseleave(function(){
$("#comments-popup").remove();
});
答案 1 :(得分:0)
$("#story-comments-text").mouseenter(function() {
var $this = this;
$.post('server.php', { name: "John", time: "2pm" }, function(data) {
$("<div id='comments-popup'></div>").html(data).appendTo($this);
});
}).mouseleave(function(){
$("#comments-popup").remove();
});
答案 2 :(得分:0)
with slowmotion =)
$("#story-comments-text").mouseenter(function() {
var $this = this;
$.post('server.php', { name: "John", time: "2pm" }, function(data) {
$("<div id='comments-popup' style='display: none'></div>").html(data).appendTo($this);
$('#comments-popup').show("slow");
});
}).mouseleave(function(){
$('#comments-popup').hide("slow", function(){
$("#comments-popup").remove();
});
});