js中from表单清空如何清空,或者重置该from

 <from id='myfrom'>
 <select>
 <option>足球</option>
 <option>篮球</option>
 名称:<input typt="text" id="name" />
  类型:<input typt="text" id="type" />
    <input type="button" id='btn' value="重置">
 </select>
 </from>

如上诉代码,执行重置,如何清空input type=text中的值,

form.reset();方法重置表单。

 代码片段2: 清除所有的表单数据
可能针对不同的表单形式,你需要调用不同类型的清楚方法,不过使用下面这个现成方法,绝对能让你省不少功夫。
在线调试  在线演示

function clearForm(form) {  
  $(':input', form).each(function() { 
    var type = this.type;  
    var tag = this.tagName.toLowerCase(); 
    if (type == 'text' || type == 'password' || tag == 'textarea')   
        this.value = "";
        else if (type == 'checkbox' || type == 'radio')    
        this.checked = false;  
        else if (tag == 'select')     
        this.selectedIndex = -1;  });
        };

可以在form表单里面加一个 然后点击就会全部清空了。

 <input type="reset">

点击这个按钮就ok,不要再写一个button了。这个csdn里面的回答的这个编辑器真的是很繁琐啊


js 部分
function clean (){
document.getElementById("myform").reset();
}