placeholder是h5的新特性,所以低浏览器不支持
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
input {
width: 436px;
height: 32px;
line-height: 32px;
padding-left: 10px;
color: #999;
}
</style>
</head>
<body>
<input type="text" value="图书满减" id="myinput">
<script>
// 表单默认效果
function addListener(element,e,fn){
if(element.addEventListener){
element.addEventListener(e,fn,false);
} else {
element.attachEvent("on" + e,fn);
}
}
var myinput = document.getElementById("myinput");
addListener(myinput,"click",function(){
myinput.value = "";
})
addListener(myinput,"blur",function(){
myinput.value = "图书满减";
})
</script>
</body>
</html>