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

Your email address will not be published.