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. jQuery function Clear() { $('.myDiv input').each(function () { $(this).val(""); x=1; }); $('.myDiv input').first().focus(); } Working Demo http://jsfiddle.net/s8vPG/2/ 来源: https://stackoverflow.com/questions/16442349/clear-form-inputs-and-keep-placeholder