模拟input的placeholder,textarea的字数监听,textarea的右下角三条线隐藏,placeholder样式修改

本文介绍了如何在低版本IE中模拟input的placeholder,并实现textarea的字数监听功能。通过聚焦和失焦事件控制input的value达到placeholder效果,同时利用input和propertychange事件监听textarea的字符数量。
摘要由CSDN通过智能技术生成

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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值