Possible Duplicate:
JavaScript: event开发者_如何学JAVA.preventDefault() vs return false
What are the cases when return false does not do the same thing as e.preventDefault() ?
(Note I'm not talking about jQuery events.. but JavaScript events in general)
The only situation I can think of is a click event on a hyperlink (if you return false in the handler you will still be redirected to the website)
Note that if its not a click event but a mousedown event on the hyperlink return false works same as e.preventDefault().
I believe that return false is equivalent to e.preventDefault(); and e.stopPropagation(); at the same time. However, I recommend that you use the functions and the return false for future and past browser compatibility:
$("#something").click(function(e){
alert("Something was clicked");
e.preventDefault();
return false;
});
Ad@m
加载中,请稍侯......
精彩评论