June 24, 201214 yr Hi, Trying to figure out how you have text appear in a search box. When you click in the box the text disappears and when you click out of it, if it's empty the word re appears. Thanks. Edited June 24, 201214 yr by Jejune
June 24, 201214 yr Its done using javascript. You use the value attribute to set a default text in the textarea. Then you use the onfocus() event to detect if the element is clicked and onblur() to detect if the element lost his focus. Then just call a function that change the value of the textarea. Something like: javascript: function focusit() { if (document.getElementById("textarea").value=="This is a textarea") { document.getElementById("textarea").value=""; } } function blurit() { if(document.getElementById("textarea").value=="") { document.getElementById("textarea").value="This is a textarea"; } } html: <input type="text" id="textarea" onfocus="focusit()" onblur="blurit()" value="This is a textarea" /> Edited June 24, 201214 yr by Leonvv
June 26, 201214 yr You can try the placeholder tag or input type="search" for example: <input type="search" name="search"> <input type="text" placeholder="Example text" name="search">
July 23, 201214 yr Make sure that Doctype is for HTML5. for using below solution. You can try the placeholder tag or input type="search" for example: <input type="search" name="search"> <input type="text" placeholder="Example text" name="search">
Create an account or sign in to comment