el.severo
el.severo

Reputation: 2277

Clear form inputs and keep placeholder

I know that using this jQuery tool

$('.myDiv input').each(function () {
   $(this).val("");
});

clears my form but can anyone help me with some suggestions how to keep placeholders of the input?

Right now the placeholders appears only after I focus on at least one input.

Upvotes: 0

Views: 7551

Answers (1)

jQuery

function Clear()
{      
     $('.myDiv input').each(function () {
   $(this).val("");
         x=1;
    });
        $('.myDiv input').first().focus();          
}

Working Demo http://jsfiddle.net/s8vPG/2/

Upvotes: 4

Related Questions