fuction method()
{
alert(this.value);
}
<input type="text" onblur="method()"/>
fuction method(btn)
{
alert(btn.value);
}
<input type="text" onblur="method(this)"/>
fuction method()
{
alert(window.event.srcElement.value);
}
<input type="text" onblur="method()"/>
<head>
<script type="text/javascript">
function InitEvent() {
var inputs = document.getElementsByTagName_r("input");
for (var i = 0; i < inputs.length; i++) {
inputs[i].onblur = OnblurEvent;
}
}
function OnblurEvent() {
// OnblurEvent是onblur的响应函数,而不是被响应函数调用的函数
// 所以可以用this来获取发生事件的对象
if (this.value.length > 0) {
this.style.backgroundColor = "white";
}
else {
this.style.backgroundColor = "red";
}
}
</script>
</head>
<body onload="InitEvent()">
<input id="Text1" type="text" />
<input id="Text2" type="text" />
<input id="Text3" type="text" />
</body>
</html>
<html>
<title>this与srcElement的区别</title>
<head>
<script type="text/javascipt>"
function btnClick(){
alert(this.value);
}
</script>
</head>
<body>
<input type="button" value="单击" onclick="btnClick()"/>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>无标题页</title>
<script type="text/javascript">
function btnClick(btn){
alert(btn.value);
}
</script>
</head>
<body>
<input type="button" onclick="btnClick(this)" value="单击" />
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>无标题页</title>
<script type="text/javascript">
function btnClick(){
alert(window.event.srcElement.value);
}
</script>
</head>
<body>
<input type="button" onclick="btnClick()" value="单击" />
</body>
</html>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有