Click here to Skip to main content
15,892,839 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

<pre lang="HTML"><table ><tr ><td onclick=javascript:alert(this.name) name="hi">hello</td></tr></table>

as you can see here alert is showing 'undefned'.
Why this code is not working now?

Thanks,

What I have tried:

Hi All,

<pre lang="HTML"><table ><tr ><td onclick=javascript:alert(this.name) name="hi">hello</td></tr></table>

as you can see here alert is showing 'undefned'.
Why this code is not working now?

Thanks
Posted
Updated 4-Nov-16 4:11am

It should be:
HTML
<table><tr><td onclick=javascript:alert(this.attributes["name"].value) name="hi">hello</td></tr></table>
 
Share this answer
 
v2
Try this
HTML
<table><tbody><tr><td onclick="javascript:alert(this.id)" id="TDId" name="hi">hello</td></tr></tbody></table>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900