$('input[type="text"]').keyup(function(e){
if(e.which === 13){
//if enter is pressed
//ignore the rest of the code below
}
doStuff();
});
在某些条件下(例如按下回车键时)跳过其余代码的正确语法是什么。我知道我只会将它包装在 if 语句中,但我想知道是否有类似于return false;
.
但是,我知道 return false 会同时执行e.stopPropagation()
and e.preventDefault()
,在这种情况下,这显然不是我真正想要的。也许返回一个布尔值?