I have a text field with placeholder text as “First Name” so when user clicks on the field
the text disappears and it allows him to type in the text
HTML
<input class="fname" type="text" placeholder="First Name"/>
JS
function placeHolderFallBack() {
if("placeholder" in document.createElement("input")) {
return; //In chrome it comes here
}else {
// works fine in IE8,FF
}
So basically the above code doesn’t work in chrome, any ideas ?
In chrome and safari the placeholder attribute works on keyup. It disappears when you start typing.
Still if it is really needed try this approach
DEMO – http://jsfiddle.net/NL2Dr/2/