td属性中的this.name不起作用 [英] This.name in td attribute is not working

查看:65
本文介绍了td属性中的this.name不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



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

推荐答案

它应该是:

It should be:
<table><tr><td onclick=javascript:alert(this.attributes["name"].value) name="hi">hello</td></tr></table>


试试这个

Try this
<table><tbody><tr><td onclick="javascript:alert(this.id)" id="TDId" name="hi">hello</td></tr></tbody></table>


这篇关于td属性中的this.name不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆