Clear text area

后端 未结 11 1504
终归单人心
终归单人心 2020-12-01 06:04

In Onselect event I have script:

$(\"#vinanghinguyen_images_bbocde\").val(\'\');
$(\"#vinanghinguyen_images_bbocde\").val(vinanghinguyen_final_bbcode);


        
相关标签:
11条回答
  • 2020-12-01 06:22

    This works:

    $('#textareaName').val('');
    
    0 讨论(0)
  • 2020-12-01 06:23

    try this

     $("#vinanghinguyen_images_bbocde").attr("value", ""); 
    
    0 讨论(0)
  • 2020-12-01 06:24

    Use $('textarea').val('').

    The problem with using $('textarea').text('') , or $('textarea').html('') for that matter is that it will only erase what was in the original DOM sent by the server. If a user clears it and then enters new input, the clear button will no longer work. Using .val('') handles the user input case properly.

    0 讨论(0)
  • 2020-12-01 06:27

    Rather simpler method would be by using JavaScript method of innerHTML.

    document.getElementById("#id_goes_here").innerHTML = "";
    

    Rather simpler and more effective way.

       

    0 讨论(0)
  • 2020-12-01 06:29

    This method removes not only child (and other descendant) elements, but also any text within the set of matched elements. This is because, according to the DOM specification, any string of text within an element is considered a child node of that element.

    $('textarea').empty()
    
    0 讨论(0)
  • 2020-12-01 06:30

    Try this,

    $('textarea#textarea_id').val(" ");
    
    0 讨论(0)
提交回复
热议问题