js default event canceled

  1. To prevent the event capture and bubbling

      : Sub-class event will be issued the same type of parent events,

       w3c standard a method window.event.stopPropagation also an event object (Event), the role is to prevent the target element bubbling event, but will not prevent the default behavior.

      IE is used window.event..cancelBubble = true

 

  2. prevent the default event (a jump label ,, type = submit submitted  when the Event object cancelable false, indicating that there is no default behavior, then even if there is a default behavior, call the preventDefault also will not work .)

    w3c method is the window.event. the preventDefault (),

    IE is the use of the window.event. .ReturnValue = to false;

  

  3.jQuery usage

    Prevent the default event  return false does not stop bubbling 

       <a href="http://www.baidu.com" onclick="return false">llll</a>
 
    jQuery return false; prevent the default event and event bubbling
    $("#testC").on('click',function(){
      return false;
    });

Guess you like

Origin www.cnblogs.com/guyuedashu/p/11810278.html