How do you pass the target element as an argument to an inline event handler?
Whew! First off, my apologies for the title, I don't speak English often.
My question is, using an inline event registration, how can I pass the target element as an argument? Like this:
<element onClick='someEvent(thisElement)'></element>
What I have tried:
开发者_如何学Python<element onClick='someEvent(this)'></element>
The code above is not working. Please help... Thank's in advance! I don't want to use addEventHandler 'coz the element will be created dynamically.
Looks fine to me
<script type="text/javascript">
function someEvent(t) {
alert(t.tagName)
}
</script>
<a onclick='someEvent(this)'>Click me</a>
I think the cause of the problem is dynamic element generation. How are you adding the attribute to the element?
Why not just use addEventHandler
during the dynamic element generation?
精彩评论