How to cancel or reset specific form values?

后端 未结 5 1918
感情败类
感情败类 2021-01-23 00:29

I have this code


  
    

<
5条回答
  •  长情又很酷
    2021-01-23 01:13

    First of all, I suggest you use a button instead of a reset button. Then you can try this

    document.getElementById('button').onclick = function() {
        var inputs = document.getElementsByName('s');
        for (var i = 0; ii = inputs.length; i < ii; i++) {
            inputs[i].value = '';
        }
    }
    

    However, if you want to use a reset button, you should prevent its default action by calling event.preventDefault() function.

提交回复
热议问题