Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMIHA W.LEE
PHP Development Techdegree Graduate 25,452 PointsThe Event Target question
After watching the tutorial, I feel a little confusion from the course, the question as follows:
If you dont set up to event.target on the function, only plain html tag or class selected by Jquery, and also they have same content, same classes, same html tag. When you click on either one of these button, why both span appeared?
Ok, after both span appeared, you set to your function to the event. When the $(event.target).show, why the button still appear from the webpage? And also, why you need to set the span tag also to the event.target?
3.As I mentioned from beyond, When you click either one of the button, two contents show up. But, on the event.target method It only shows single one of them. Why this happens?
- Lastly, I know 'this' based on your code, and refer to different scope, but is it mostly refers to event.target?
I know my description Is not fully understand, but I hope someone can help me out, Thank you so much!!
1 Answer
Steven Parker
231,236 PointsA feature of a jQuery object is that it can refer to a collection of elements. So if you use a selector that applies to more than one element, and perform a method on it, the same action will occur on each element the selector refers to.
The event.target
is a way you can isolate the specific element that triggered an event.
Inside an event handler, "this" is set to refer to the triggering element. So it would be the same as event.target
.
MIHA W.LEE
PHP Development Techdegree Graduate 25,452 PointsMIHA W.LEE
PHP Development Techdegree Graduate 25,452 PointsSorry for the late reply. Thank you so much, i got it.