Clear text area

后端 未结 11 1505
终归单人心
终归单人心 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:31

    I agree with @Jakub Arnold's answer. The problem should be somewhere else. I could not figure out the problem but found a work around.

    Wrap your concerned element with a parent element and cause its html to create a new element with the id you are concerned with. See below

    <div id="theParent">
        <div id="vinanghinguyen_images_bbocde"></div>
    </div>
    
    'onSelect'    : function(event,ID,fileObj) {
     $("#theParent").html("<div id='vinanghinguyen_images_bbocde'></div>");
     $("#vinanghinguyen_result").hide();
     $(".uploadifyQueue").height(315);
    }
    
    0 讨论(0)
  • 2020-12-01 06:38

    When you do $("#vinanghinguyen_images_bbocde").val('');, it removes all the content of the textarea, so if that's not what is happening, the problem is probably somewhere else.

    It might help if you post a little bit larger portion of your code, since the example you provided works.

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

    I just tried using this code and @psynnott's answer was correct though I needed to know it would work repeatedly, seems to work with jquery 1.7.1 >

    I modified the jfiddle to the following http://jsfiddle.net/Rjj9v/109/

    $('#mytext').text('');
    

    This is not a new answer @psynnott is correct I am just providing a more concise example that shows the textarea is still working after the clear because if you use .val("") the text area stops working

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

    Correct answer is: $("#selElement_Id option:selected").removeAttr("selected");

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

    I believe the problem is simply a spelling error when writing bbcode as bbocde:

    $("#vinanghinguyen_images_bbocde").val('')
    

    should be:

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