JSFiddle - React, Tailwind, and code Playground
HTML
<input id="textfield" name="textfield" type="text" placeholder="enter something" />
<input id="textfield" name="textfield" type="text" data-placeholder="enter something">
JavaScript
var inputs = document.getElementsByTagName("input");
for (var i = 0; i < inputs.length; i++) {
inputs[i].value = inputs[i].getAttribute('data-placeholder');
inputs[i].addEventListener('focus', function() {
if (this.value == this.getAttribute('data-placeholder')) {
this.value = '';
}
});
inputs[i].addEventListener('blur', function() {
if (this.value == '') {
this.value = this.getAttribute('data-placeholder');
}
});
}