Java, Struts 1 & 2, Spring, Hibernate, iBatis, Jasper Reports, RDBMS, JDBC, JSP, Servlet, HTML, JS, AJAX, JQuery
Thursday, June 15, 2017
Event.stopPropagation() and Event.preventDefault()
1. event.stopPropagation() stops an event from bubbling up the event chain
2. event.preventDefault() will only prevent browser’s default action on that event from occurring, but the event still propogates up the event chain.
Example
$("#myDiv").click(function() {
alert('click on #myDiv');
});
$("#divButton").click(function(e) {
alert('button click');
e.stopPropagation();
});
Subscribe to:
Posts (Atom)