标签:
<!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>
标签:
原文地址:http://www.cnblogs.com/ld-swust/p/5727370.html