1.模拟input的placeholder
(有些情况,需要兼容到低版本的IE,但placeholder在低版本的IE上不展示,就得兼容一下。思路:模拟placeholder,通过value来,使用聚焦和失焦事件控制)
2.textarea的字数监听有input和propertychange,判断浏览器,进行初始赋值;
3.代码
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>input textarea</title>
<style type="text/css">
.input_new {
resize: none;
}
textarea::-webkit-input-placeholder,
input::-webkit-input-placeholder {
color: #cccccc;
}
textarea::-moz-input-placeholder,
input::-moz-input-placeholder {
color: #cccccc;
}
textarea::-ms-input-placeholder,
input::-ms-input-placeholder {
color: #cccccc;
}
</style>
<script src="https://cdn.bootcss.com/jquery/3.3.0/jquery.js"></script>
</head>