因为每点一次就绑定多一次 这样试试 var b=false; function right_click() { var event_top=event.y+"px"; var event_left=event.x+"px"; if(event.button==2) { $("#div_popMenu").show("slow"); $("#div_popMenu").css("top",event_top); $("#div_popMenu").css("left",event_left); $("#div_popMenu ul").focus();
这样试试
var b=false;
function right_click()
{
var event_top=event.y+"px";
var event_left=event.x+"px";
if(event.button==2)
{
$("#div_popMenu").show("slow");
$("#div_popMenu").css("top",event_top);
$("#div_popMenu").css("left",event_left);
$("#div_popMenu ul").focus();
if(!b){
$("#div_popMenu ul li").each(function(i){
$(this).hover(
function(){$(this).css("background-color","White");},
function(){$(this).css("background-color","Silver");}
);
$(this).click(function(){
alert($(this).html());
});
});
b=true;
}
}
$("#div_popMenu").hover(
function(){$(this).css("display","block");},
function(){$(this).css("display","none");}
)
}