JSFiddle - React, Tailwind, and code Playground
by James Allardice
HTML
<input type="text" name="store_name" id="store_name" />
JavaScript
$(function() {
/*function isPlaceholderSupported() {
var input = document.createElement('input');
return ('placeholder' in input);
}*/
var placeholderSupport = /*isPlaceholderSupported()*/ false;
if (placeholderSupport == false) {
$('#store_name').val('Store Name');
}
$('#store_name').focus(function() {
if (placeholderSupport == false) {
if ($(this).val() == 'Store Name') {
$(this).val('');
}
}
});
$('#store_name').blur(function() {
if (placeholderSupport == false) {
if ($(this).val() == '') {
$(this).val('Store Name');
}
}
});
});