JSFiddle - React, Tailwind, and code Playground
HTML
<div>
<textarea class="comment_empty">Write a comment</textarea><br />
<input type="submit" id="submit" value="Submit" style="display: none" />
</div>
CSS
.comment_empty {
color: gray;
height: 30px;
}
.comment_filled {
color: black;
height: 100px;
}
JavaScript
$(document).ready(function(){
var submit = $("#submit");
$("textarea").blur(function() {
if ($(this).val() == "") {
$(this).val("Write a comment")
.removeClass("comment_filled")
.addClass("comment_empty");
submit.hide();
}
}).focus(function() {
if ($(this).val() == "Write a comment") {
$(this).val("")
.removeClass("comment_empty")
.addClass("comment_filled");
submit.show();
}
});
});