Difference between revisions of "Event Delegation"

From rbachwiki
Jump to navigation Jump to search
Line 1: Line 1:
'''Event Bubbling ''' </br >
'''Event Bubbling ''' <br />
When a child element is clicked, the event bubbles all the way up the dom. This means that you can capture the child element that was activated through the bubbling up effect from the parent. </br>
When a child element is clicked, the event bubbles all the way up the dom. This means that you can capture the child element that was activated through the bubbling up effect from the parent. <br />
You can capture the event by passing the even to the function and capturing the target
You can capture the event by passing the even to the function and capturing the target
  var myfun = function(event){
  var myfun = function(event){
  console.log(event.target)
  console.log(event.target)
  }
  }

Revision as of 19:30, 26 November 2016

Event Bubbling
When a child element is clicked, the event bubbles all the way up the dom. This means that you can capture the child element that was activated through the bubbling up effect from the parent.
You can capture the event by passing the even to the function and capturing the target

var myfun = function(event){
console.log(event.target)
}