this指触发事件的对象,接下来为大家分享下javascript中onclick(this)的用法,感兴趣的朋友可以参考下哈,希望对你有所帮助
<input id="myinput" type="text" value="javascript中onclick中的this" οnclick="javascript:test(this);"/>
function test(obj){
<span style="white-space:pre"> </span>alert(obj); //[object HTMLInputElement]
<span style="white-space:pre"> </span>alert(obj.id); //myinput
<span style="white-space:pre"> </span>alert(obj.value); //javascript中onclick中的this
}