Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 17th, 2012  |  syntax: None  |  size: 0.27 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. What's the difference between event.stopPropagation and event.preventDefault?
  2. <div id="foo">
  3.  <button id="but" />
  4. </div>
  5.  
  6. $("#foo").click(function() {
  7.    // mouse click on div
  8. });
  9.  
  10. $("#but").click(function(ev) {
  11.    // mouse click on button
  12.    ev.stopPropagation();
  13. });