How to clear the placeholder on focus
Posted by navaneeth on May 9, 2013 in General, HTML, Javascript, Jquery | No comments yet
By default place holder will stay there when we click on the text box, We can do it by writing simple code with javascript
as follows
<script type="text/javascript">
$(function(){
$("input:text").each(function ()
{
// store default value
var v = $(this).attr('placeholder');
$(this).focusin(function ()
{
$(this).attr('placeholder','');
}).focusout(function ()
{
$(this).attr('placeholder',v);
});
});
})
</script>
Don’t forget to include jQuery
The above code is mentioned only for text boxes we can add it for textarea also

Leave a Reply