I know it's been quite awhile, but I'm surprised nobody suggested:
txt.unbind();
txt.bind("keyup",function(event){
if(event.keyCode==13)
{
var nu = $("#debug").html();
nu+="<br>enter";
$("#debug").html(nu);
}
});
If somehow txt
got bound already, calling unbind before your new bind should fix it. Of course it's preferable to figure out why it's being bound twice. This just happened to me, because I accidentally had my JavaScript file included twice. Calling unbind helped me determine that was the problem.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…