Clear form inputs and keep placeholder

自古美人都是妖i 提交于 2019-12-06 16:46:35

问题


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.


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!