87,907
社区成员
发帖
与我相关
我的任务
分享
<html>
<head>
<script>
function test1(a)
{
document.getElementById("ipt").fireEvent("onblur");
//这里怎么获取test2执行后的返回值?触发事件不一定要用fireEvent,其他方法能获取到相似效果也可以。
var e=document.getElementById("ipt").onblur();
alert(e)
}
function test2(obj)
{
if (obj.value == 'test')
{
return false;
}
return true;
}
</script>
</head>
<body>
<input id="ipt" type="text" name="ipt" onblur="return test2(this)" />
<button onclick="test1()">test </button>
</body>
</html>
<html>
<head>
<script>
function test1(a) {
alert(document.getElementById("ipt").onblur());
}
function test2(obj) {
return obj.value != 'test';
}
</script>
</head>
<body>
<input id="ipt" type="text" name="ipt" onblur="return test2(this)" />
<button onclick="test1()">test </button>
</body>
</html>