I have the following encoding and would like to clear the form from all fields that have the same name
. But I do not know why it does not clear the fields
PS: What properties of input text
can I use for this kind of thing?
function limpaCampos() {
document.getElementsByName("form_txt").value = ''; // Limpa o campo
console.log(document.getElementsByName("form_txt").value);
}
<html>
<body>
<input id="01" type="text" name="form_txt"/>
<input id="01" type="text" name="form_txt"/>
<input type="button" onclick="limpaCampos();"/>
</body>
</html>