<script>
var obj = document.getElementsByName('user')[0]
var os = document.createElement('span')
var sp=document.body.insertBefore(os,obj)
obj.onblur = function(){
sp.innerText='合法'
alert(111)
}
</script>
=======================================event来判断当前对象.如果非特定元素,执行onblur
快采纳啊!亲测可用。
=======================================
<div id='list' onmousemove="c()">
<form method='post' action='' id='form'>
<dl >
<dd>
请填写权限名称:
<input type='text' name='pername' id='pername'/><span class='must'>
</dd>
<dd>
<input type='submit' class='submit' value='提交'id='submit'/>
</dd>
</form>
</dl>
</div>
<script type='text/javascript'>
var cur
window.onload=function (){
var fm=document.getElementById('form')
var pername=document.getElementById('pername')
fm.onsubmit=check_submit
pername.onblur=function (){
if(cur!="submit")
alert('pername失去焦点')
}
}
function check_submit (){
alert('提交l')
}
function c()
{
cur=event.target.type
}
</script>
var node = document.getElementById("#id") // 假设这是目标inputnode.onblur = function() {
alert(this.value) // 这就是input框的value属性值
}