this指触发事件的对象
复制代码 代码如下:
<input id="myinput" type="text" value="javascript中onclick中的this" onclick="javascript:test(this);"/>
复制代码 代码如下:
function test(obj){
alert(obj); //[object HTMLInputElement]
alert(obj.id); //myinput
alert(obj.value); //javascript中onclick中的this
}
最后
以上就是真实寒风最近收集整理的关于javascript中onclick(this)用法介绍的全部内容,更多相关javascript中onclick(this)用法介绍内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复