Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
652 views
in Technique[技术] by (71.8m points)

jquery - Clear text area

In Onselect event I have script:

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

I want clear text area id="vinanghinguyen_images_bbocde" before add value to it. but textarea add add add add and value and not clear. I want clear it before add value

I use uploadify here is my function

<script type = "text/javascript" >
  $(document).ready(function() {
    vinanghinguyen_bbcode = '';
    vinanghinguyen_final_bbcode = '';
    vinanghinguyen_link = '';
    vinanghinguyen_final_derect_link = '';
    response = '';

    $('#file_upload').uploadify({
      'uploader'  : '{SITE_FULL_URL}/uploadify/uploadify.swf',
      'script'    : '{SITE_FULL_URL}/uploadify/uploadify.php',
      'cancelImg' : '{SITE_FULL_URL}/uploadify/cancel.png',
      'folder'    : 'data/picture_upload/2011',
      'auto'      : false,
      'multi'     : true,
      'buttonText': '',

      'onComplete': function(event, ID, fileObj, response, data) {
        vinanghinguyen_bbcode = '[IMG]' + 'http://cnttvnn.com' + response + '[/IMG]' + '
';
        vinanghinguyen_final_bbcode = vinanghinguyen_final_bbcode + vinanghinguyen_bbcode;
        vinanghinguyen_derect_link = 'http://cnttvnn.com' + response + '
';
        vinanghinguyen_final_derect_link = vinanghinguyen_final_derect_link + vinanghinguyen_derect_link;

        $("#vinanghinguyen_images_bbocde").val('').val(vinanghinguyen_final_bbcode);
      //$("#vinanghinguyen_images_derect_link").val(vinanghinguyen_final_derect_link);
        $("#vinanghinguyen_result").show();
        $(".uploadifyQueue").height(5);
      },

      'onSelect': function(event, ID, fileObj) {
        $("#vinanghinguyen_images_bbocde").val('');
        $("#vinanghinguyen_result").hide();
        $(".uploadifyQueue").height(315);
      },
    });
  });
</script>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...