为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

单选按钮如何不显示id 而是undefined

2018-03-01 3页 doc 13KB 28阅读

用户头像

is_153723

暂无简介

举报
单选按钮如何不显示id 而是undefined单选按钮如何不显示id 而是undefined c_a_3(); 单选按钮怎么不显示id 而是undefined !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN html head meta http-equiv= Content-Type content= text/html; charset=gbk script !-- function getVById(){ var tt=this.id; alert(tt); } -- ...
单选按钮如何不显示id 而是undefined
单选按钮如何不显示id 而是undefined c_a_3(); 单选按钮怎么不显示id 而是undefined !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN html head meta http-equiv= Content-Type content= text/html; charset=gbk script !-- function getVById(){ var tt=this.id; alert(tt); } -- /script /head body input type= radio id= test11 name= test11 value= 1 onclick= getVById() / 测试1 input type= radio id= test12 name= test11 value= 2 onclick= getVById() / 测试2 /body html HTML this 分享到: ------解决-------------------------------------------------------- 引用: Quote: 引用: Quote: 引用: 直接在function里面获取的this是Window对象 + !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN html head meta http-equiv= Content-Type content= text/html; charset=gbk script type= text/javascript window.onload= function(){ var atr = document.getElementsByTagName('input'); //alert('0'); for(i=0;i atr.length;i++) { atr[i].onclick=function (){ var tt=this.id; alert(tt); } } /script /head body input type= radio id= test11 name= test11 value= 1 onclick= getVById() / 测试1 input type= radio id= test12 name= test11 value= 2 onclick= getVById() / 测试2 /body html 这里我还是直接用this 但又行了 这是什么原因啊 也是直接在函数里面调用的
/
本文档为【单选按钮如何不显示id 而是undefined】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索