Best Event Propagation training with the list of digital marketing companies in delhi ncr
A.Event Propagation Training Best Tutorial
Next, I would like to get into propagation. In other words how the men can kind of do what's called bubbling up to the Dong and some don't. It's important to stop the propagation and show an example of that. Let's say we have some kind of node that if we click on it it gets kind of some kind of border or a background colour applied to it. When we click out of it removes the background colour. So let's do a quick example of that with another div. Please check here our list of digital marketing companies in delhi ncr 2019. Give Id just call it background slash div. And inside this, we can have some kind of I don't know.
H. H. I am size H- header so this should just look pretty basic at this point. It just needs to the header's the room when we click on it we want to add list of digital marketing companies in delhi ncr which class we click outside of it. We want to remove the class and us kind of know enough to do that already on top digital agencies right now You know I'm just going to do style attacks instead of putting it into a separate CSSA file. I'll do it.
B. Updated Event Propagation Techniques
i.Let's see here. The head of the document the style style and we can say let's see Dot background colour. Background. You can use just a shorthand background property background orange border one-pixel solid black.
ii. Just a test so what it looks like. Let's see if we add that class right away. Background colour. Caylus tester. Oh OK. So we have this list of digital marketing companies in delhi ncr let's say an earthquake anywhere inside the city we want to apply this background.
iii. We want it to be removed. So I'm going to remove it here. So we will grab this div and I'll just leave all this code alone up there kind of separate it out. So say conc current equals document get element by ID.
iv. Background and then backgrounds dot add event lists and or and instead of quick you can do something called mouse down. It's similar. And when we check list of digital marketing companies in delhi ncr here. So let's say switch background and function switch background and want to test out something kind of cool.
C. Properties of Event Propagation
We can say if he does which we can check the which property when we use mouse down so just a quick peek at it here console log a great way to learn about our code. Let's open up our console refresh it click on it. And if you take a look at the which Let's see which do you. So I did a left click which is a one right click. Let's see if another event fires really quick we can see that it did it. And here you can see which is three if I do a middle click on my mouse will be smaller.
This is different which this is too. So if you think if you're mostly kind of in between your left and your right smart but right mouse button. So one two three kinds of makes sense.
And we can basically do something like you do and if check if E dot which equals one because of a background Daut class list Daut toggle background colour. This is when we want to check list of digital marketing companies in delhi ncr Let's see if we get it to work.
Quick quick quick quick quick quick quick. Cool. So it has an effect I want but only if I click within a certain area if I right click it doesn't do anything now which is actually what I wanted so that's cool but that's not particularly the behaviour I wanted. I just wanted to add the class. So let's see. We will do background Daut class list add let's see background colour right.
D. Test it out
Let's do a sanity check. . Quick. Cool. Now how do we do a remove? Well, we should know enough by now to be able to do that background Daut an event listener focus and you know what Maysville we use our function switch background and it kind of makes sense kind of extract some logic here so we can do if Itote type equals mows down background class list add a background colour.
We can do it. Else if as well. If Iraq type equals focus out background's class list remove background colour already let's test refresh Kwek Kwek somewhere else. OK. So our focus is not really working. So we can use our knowledge of the dorm to fix that. So instead of looking forward to different events, we can kind of come up with a bit of a more elegant solution and we can do document it at the event listener. And you know we can just leave it as click actually switch background.
E. Final Conclusion
And then enter switch background function. Let's check we can say conchas been quick equals and now we can use our element we grabbed out background dot contains And there's another property we haven't discussed yet which is Target. So events have a target property right so just to take a quick peek. Let's see Consolo has been kicked so this will return either true or false.
Let's see list of digital marketing companies in delhi ncr 2019, Refresh quick true quick elsewhere. False. Pretty neat. Right. So if you want to see the event lets Consolo that as well. A log. And this will tell us wherever we're clicking it's going to give us a mouse event and we can see that it has a target value.
So let's go down to target because it is an age to click the button. Let's see what happens. Quick right. So this also triggered a mouse event because we added a listener on the entire document. And this one will have a target value as well. Target is a button in that particular case. So we can use that to our advantage. So it has been clicked.