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
	    }


posted on 2013-04-18 18:38  itmyhome  阅读(152)  评论(0编辑  收藏  举报

导航