How can I clear the input text after clicking

后端 未结 14 1732
遥遥无期
遥遥无期 2021-01-31 07:26

Using jQuery, how can I clear the input text after I made a click? By default, the value remains in the input field.

For example, I have an input text and the value is <

14条回答
  •  一生所求
    2021-01-31 07:36

    Using jQuery ...

    $('#submitButtonsId').click(
        function(){
            $(#myTextInput).val('');
        });
    

    Using pure Javascript ...

    var btn = document.getElementById('submitButton');
    btn.onclick = function(){ document.getElementById('myTextInput').value="" };
    

提交回复
热议问题