比如一个button放在一个form中,这个button的Default就是提交(submit),但如果你不想让他提交,就可以用e.preventDefault();
打个比方:
$(document).ready(function(){
$("button").click(function(e){
$("#show").fadeTo("fast",0);
e.preventDefault();
});
}
在一个form里有button,还有一个id=show的div(上点颜色),你可以保留e.preventDefault();和去掉e.preventDefault();试试看,效果不同的。
e.preventDefault();
猜你喜欢
转载自serena-cc7.iteye.com/blog/2410810
今日推荐
周排行