Reset textbox value in javascript

后端 未结 9 1006
执笔经年
执笔经年 2020-12-13 17:16

If I have a input textbox like this:


How can I set the value of the t

相关标签:
9条回答
  • 2020-12-13 17:47

    I know this is an old post, but this may help clarify:

    $('#searchField')
        .val('')// [property value] e.g. what is visible / will be submitted
        .attr('value', '');// [attribute value] e.g. <input value="preset" ...
    

    Changing [attribute value] has no effect if there is a [property value]. (user || js altered input)

    0 讨论(0)
  • 2020-12-13 17:52

    Try using this:

    $('#searchField').val('');
    
    0 讨论(0)
  • 2020-12-13 17:52

    this is might be a possible solution

    void 0 != document.getElementById("ad") &&       (document.getElementById("ad").onclick =function(){
     var a = $("#client_id").val();
     var b = $("#contact").val();
     var c = $("#message").val();
     var Qdata = { client_id: a, contact:b, message:c }
     var respo='';
         $("#message").html('');
    
    return $.ajax({
    
        url: applicationPath ,
        type: "POST",
        data: Qdata,
        success: function(e) {
             $("#mcg").html("msg send successfully");
    
        }
    
    })
    

    });

    0 讨论(0)
提交回复
热议问题