js执行终止的方法

122 阅读1分钟

我们在前端执行判断时如果条件不成立就让他禁止执行后边的程序 分三种方法:、

(一)在function里面

(1)return;

(2)return false;

(二)非function方法里面

alert("before error.");

throw SyntaxError();

alert("after error.");

(三)非function方法里面

$("body").on("tap",".go-detail",function(e){

 e.preventDefault();

 e.stopPropagation();

}