简体   繁体   中英

Javascript form reset

I use this code to reset my radio buttons, but it doesn't reset my text fields. How can I make it reset my text fields?

function rensa(obj)
{
    for(var i=0; i<obj.length; i++)    
         obj[i].checked = false;

}

您为什么不只使用reset() ,例如:

document.myform.reset();

Form元素具有reset()方法

function rensa(obj)
{
    for(var i=0; i<obj.length; i++){    
         obj[i].checked = false;
         obj[i].value = "";
  }

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM