为了账号安全,请及时绑定邮箱和手机立即绑定

onclick="clearinfo(this) 中的this代表什么意思(有人说它指代标签a,但在body有好几个标签a啊)

onclick="clearinfo(this) 中的this代表什么意思(有人说它指代标签a,但在body有好几个标签a啊)

向日葵一族 2016-12-12 07:29:12
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><script>function changewebsize(){    document.getElementById("webSite").innerHTML="<a href='http://163.com'>网易</a>";    }     function clearinfo(obj){                 obj.value="";         obj.style.color="black";         }</script></head><body><div id="webSite"><a href="http://baidu.com">百度</a></div><input type="button" value="改变层内容"  onclick="changewebsize()" /><br /><br /><input type="text" name="city" value="请选择您工作的城市" onclick="clearinfo(this) " class="wordstext"/>&nbsp;&nbsp;&nbsp;&nbsp;<input type="text"  name="city" value="请选择您工作的第二志愿城市" onclick="clearinfo(this)" class="wordstext" /><br /><br /><input type="text" name="city" value="请选择您工作的城市"  onclick="clearinfo(this) " class="wordstext"/>&nbsp;&nbsp;&nbsp;&nbsp;<input type="text"  name="city" value="请选择您工作的第二志愿城市"  onclick="clearinfo(this) " class="wordstext" /><br /><br /><input type="text" value="显示上面的input所有内容"   onclick="clearinfo(this) " class="wordstext" />&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" value="显示所有城市所有内容" onclick="clearinfo(this) " class="wordstext"/>&nbsp;&nbsp;&nbsp;&nbsp;</body></html>
查看完整描述

8 回答

已采纳
?
串猪神

TA贡献155条经验 获得超200个赞

点击的那个元素

查看完整回答
6 反对 回复 2016-12-12
?
慕虎8944357

TA贡献4条经验 获得超2个赞

this  一般用于指定选择的是当前对象

查看完整回答
1 反对 回复 2016-12-13
?
一只废喵

TA贡献8条经验 获得超4个赞

个人理解 ,就是你代码里将要执行的函数名或者按钮或者什么的,有毛病望指出。
查看完整回答
反对 回复 2016-12-12
?
Guard丿星魂

TA贡献18条经验 获得超1个赞


点的哪个A标签就是那个A标签

查看完整回答
反对 回复 2016-12-12
?
MicleZhou

TA贡献6条经验 获得超12个赞

this指的是当前事件所在标签上对应的元素对象。

查看完整回答
反对 回复 2016-12-12
?
云天河V

TA贡献17条经验 获得超8个赞

点击的谁就是谁,你可以看看他们的索引值

查看完整回答
反对 回复 2016-12-12
?
慕UI8820655

TA贡献15条经验 获得超4个赞

你的这个this相当于input,你点击那个input

查看完整回答
反对 回复 2016-12-12
?
cleartime

TA贡献7条经验 获得超0个赞

事件里面的this是指点击的元素,建议看看犀牛书入门

查看完整回答
反对 回复 2016-12-12
?
self_potato

TA贡献53条经验 获得超27个赞


指代当前点击元素

查看完整回答
反对 回复 2016-12-12
  • 8 回答
  • 0 关注
  • 3375 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信