我想在鼠標懸停在特定區域時在工具提示中加載數據(通過ajax)。問題是,只要我的鼠標在該區域上就可以進行ajax調用。有什麼辦法,我可以讓onmouseover(ajax call)效果只發生一次?下面是代碼:鼠標懸停操作只運行一次(如何)
$.post('calendar/event-details', {'eventId' :event.id},
function (data){
this.top = (ui.clientY + 15); this.left = (ui.clientX - 230);
$('body').append('<div id="vtip">' + data + '</div>');
$('div#vtip').css("top", this.top+"px").css("left", this.left+"px").fadeIn("slow");
$('div#vtip').css("position","absolute");
$('div#vtip').css("z-index", "+99");
})
哪裏是你的HTML,並在那裏爲你的代碼結合的鼠標懸停事件? – Shef