event.preventDefault() vs return false;

우선 둘다 기본 동작을 막는것이다. 이 의미는 만약 checkbox 를 선택했을때 onclick 등에 이벤트를 걸었을시, 해당 이벤트내에서 위의 2가지중 하나를 하면 checkbox 에 check 가 되지 않는다. 물론 펑션의 내용은 잘 실행된다.

아주 좋은 답이 있는데 stackoverflow 에 나와있는 답이다.

간단히 말하면 return false 는 preventDefault() 와 stopPropagation() 의 기능 둘다를 처리한다고 한다.

return false from within a jQuery event handler is effectively the same as calling bothe.preventDefault and e.stopPropagation on the passed jQuery.Event object.

e.preventDefault() will prevent the default event from occuring,e.stopPropagation() will prevent the event from bubbling up and return falsewill do both. Note that this behaviour differs from normal (non-jQuery) event handlers, in which, notably, return false does not stop the event from bubbling up.


+ Recent posts