javascript中onclick(this)详解编程语言

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 
	    }

原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/14550.html

(0)
上一篇 2021年7月19日 16:55
下一篇 2021年7月19日 16:55

相关推荐

发表回复

登录后才能评论