码迷,mamicode.com
首页 > 其他好文 > 详细

contenteditable placeholder

时间:2016-08-01 22:45:54      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.content.placeholder::after {
  content: ‘留下你想说的话吧‘;
  color: #ccc;
}
</style>
</head>
<body>
<div class="content placeholder" contenteditable="true">

</div>

<script>
document.getElementsByClassName(content)[0].oninput = function() {
  if(this.innerHTML.length != 0) {
    this.classList.remove(placeholder);
  } else {
    this.classList.add(placeholder);
  }
}
</script>
</body>
</html>

 

contenteditable placeholder

标签:

原文地址:http://www.cnblogs.com/ld-swust/p/5727370.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!