Is there a quick way in javascript to select the element that called the function on an event such as onmouseover or onclick or do i have to use standard document selection in the method to select the element.
asked Sep 5, 2010 at 19:46
user398371
8652 gold badges10 silver badges15 bronze badges
3 Answers 3
element.onclick = function () {
// this == element
// e.g. this.className = 'Highlighted';
}
Ujjwal Singh
5,0384 gold badges40 silver badges56 bronze badges
answered Sep 5, 2010 at 19:50
Casey Chu
25.5k10 gold badges42 silver badges59 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
check out this?
answered Sep 5, 2010 at 19:49
Ben
16.6k9 gold badges47 silver badges66 bronze badges
Comments
If I understand your question right then you should be able to use the "this" keyword.
answered Sep 5, 2010 at 19:49
Paulie Waulie
1,69015 silver badges23 bronze badges
Comments
lang-js