Hi,
I have an element like this:
<p id='foo' onclick='go()'>hi</p>
function go() {
}
how do I get access to the element that generated the click (the p element in this case)? Do I just do:
function go() {
var clicked = this;
}
Thanks
Hi,
I have an element like this:
<p id='foo' onclick='go()'>hi</p>
function go() {
}
how do I get access to the element that generated the click (the p element in this case)? Do I just do:
function go() {
var clicked = this;
}
Thanks
Like this:
<p id='foo' onclick='go(this)'>hi</p>
function go(elem) {
}
You could pass this as an argument:
<p id='foo' onclick='go(this);'>hi</p>
function go(clicked) {
}