javascript - how to use HTML5 placeholder attribute with backward-compatibility in mind? -


i'd use html5's placeholder attribute (you can see in cation in newsletter @ thought results). when use older browsers, of course, don't render anything. can use javascript imitate it, then, shouldn't use , it's done old way. how can have both html5 placeholder attribute, , @ same time simulate older browsers?

you can detect if browser supports attribute:

http://diveintohtml5.info/detect.html#input-placeholder

function supports_input_placeholder() {     var = document.createelement('input');     return 'placeholder' in i; } 

if does, nothing. if doesn't, can use js grab placeholder value , insert field see fit (perhaps default value) , add appropriate interactions simulate html5 placeholder behaviors.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -