JSFiddle - React, Tailwind, and code Playground
HTML
<div class="placeholder" placeholder="Type something..." contenteditable="true"></div>
CSS
.test {
width: 500px;
height: 70px;
background: #f5f5f5;
border: 1px solid #ddd;
padding: 5px;
}
.test[placeholder]:empty:before {
content: attr(placeholder);
color: #555;
}
JavaScript
var $input = $(".placeholder");
function clearPlaceHolder() {
if ($input.text().length == 0) {
$input.empty();
}
}
$input.keyup(clearPlaceHolder);
$input.click(clearPlaceHolder);
$input.change(clearPlaceHolder);
// Copy/paste/cut events http://stackoverflow.com/q/17796731
$input.bind('input', (clearPlaceHolder));