码迷,mamicode.com
首页 > Windows程序 > 详细

window.event.srcElement与window.event.target 触发事件的元素

时间:2016-05-25 00:07:46      阅读:306      评论:0      收藏:0      [点我收藏+]

标签:

IE浏览器支持window.event.srcElement , 而firefox支持window.event.target;
<input type="text" onblur="alert(this.value)">//正确滴

******************
<input type="text" onblur="method()">//错的啦
<script>
function method(){
alert(this.value);
}
</script>

*******************
<input type="text" onblur="method(this)">//又对啦
<script>
function method(ipt){
alert(ipt.value);
}
</script>

*****************
<input type="text" onblur="method()">// 正确
<script>
function method(){
alert(window.event.srcElement.value);//用window.event.srcElement取得触发事件的控件,俺就是这么酷-.-

}
</script>

***************
 
 

window.event.srcElement与window.event.target 触发事件的元素

标签:

原文地址:http://www.cnblogs.com/vagebird/p/5525252.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!