JSFiddle - React, Tailwind, and code Playground
HTML
<input type='text' class='placeholder' data-title='hello'>
JavaScript
$('.placeholder').each(function(){
$(this).data('placeholder', $(this).attr('data-title'));
$(this).val($(this).attr('data-title'));
});
$('.placeholder').live('click', function(){
if ($(this).val() == $(this).data('placeholder')) {
$(this).val('');
}
});
$('.placeholder').live('keydown', function(){
if ($(this).val() == $(this).data('placeholder')) {
$(this).val('');
}
});
$('.placeholder').live('blur', function(){
if ($(this).val().trim() == '') {
$(this).val($(this).data('placeholder'));
}
});