有一个html表格,在每一行中,我添加了“编辑”图标,当鼠标进入图标时,它会弹出一个菜单。在 document.ready 函数中,事件 mouseenter 生效。但是如果我通过 dajax 添加一个新行,事件 mouseenter 是无效的。
function add_finding(table_type){
if(!check_finding_attribute(table_type))
return;
else{
Dajaxice.codeinsight.add_finding(Dajax.process,get_finding_attribute_dict(table_type));
reset_finding_attribute(table_type);
//reload the popup menu
$(".menubox").each(function(){
var menubox_id=$(this).attr("id");
var showmenu_id=menubox_id.replace("menubox","showmenu");
$.showmenu("#"+showmenu_id,"#"+menubox_id);
});
}
}
$(document).ready(function(){
jQuery.showmenu = function(showbtnid,showboxid) {
var showmenubtn = $(showbtnid);
var showmenubox = $(showboxid);
showmenubtn.mouseenter(function(e){
var thish = $(this).height();
var offset = $(this).offset();
var tipx = offset.left;
var tipy = offset.top+thish-1;
showmenubox.show().css("left",tipx).css("top",tipy);
t= setTimeout(function(){showmenubox.hide();},1000);
});
showmenubox.mouseenter(function(){
clearTimeout(t);
});
showmenubox.mouseleave(function(){
$(this).hide();
});
};
$(".menubox").each(function(){
var menubox_id=$(this).attr("id");
var showmenu_id=menubox_id.replace("menubox","showmenu");
$.showmenu("#"+showmenu_id,"#"+menubox_id);
});
});