
$(".demo").append($span)
用获得焦点onfocus和失去焦点onblur事件
<html><head>
<script>
function show(){
var test=document.getElementById("uname").value
if(test==null || test==""){
document.getElementById("abc").style.display=''
}else{
document.getElementById("abc").style.display='none'
}
}
function hide(){
document.getElementById("abc").style.display='none'
}
</script>
</head>
<body>
<input id="uname" type="text" onblur="show()" onfocus="hide()"/><span id="abc">请输入名称</span>
</body>
</html>
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)