View Full Version : how to refer to the subject node in an event handler (this)
I thought that I could refer to the current node using the 'this' keyword, as in
<button onclick='myFunc(this)'> blah </button>
where the button object would be passed into myFunc(), however, when I trace the call, I get a null object. What am I doing wrong?
glenngv
10-23-2003, 06:15 AM
works for me in IE5.5
<button name="btn" onclick='alert(this.name)'> blah</button>
can you post the myFunc() function?
Ok. Here's a fragment of exactly what I'm doing
<td class='menuitem' onclick="emailDeleteDlg('main','emails','rmallemail','')">
<a class='menuanchor' title='All Emails in All Segments'
href='javascript:this.parentNode.onclick();void 0'>
All Emails in All Segments
</a>
</td>
I get a popup indicating that this.parentNode is null
The TD is code generated by a tag library so I can't mess with that. The anchor is part of the (body/content, not sure of the right term) of one of the tags. I'm using the anchor because it has accessibility capabilities, so I can add 'accesskey' and 'title'.
ahosang
10-23-2003, 04:51 PM
Try:
<a class='menuanchor' title='All Emails in All Segments'
href="#" onclick="this.parentNode.onclick();return false">
Is there anyway to stop the screen from flashing when one uses href="#" on an anchor????
requestcode
10-23-2003, 07:37 PM
try this:
<a class='menuanchor' title='All Emails in All Segments'
href="javascript:this.parentNode.onclick();return false">
liorean
10-23-2003, 07:48 PM
wac: Try adding ";return false;" at the end of the onclick attribute.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.