Home  >  Q&A  >  body text

Insert text in textarea - Stack Overflow

I want to insert text with a fixed beginning and end but a loop in the middle in a textarea, similar to

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<mysql xmlns:xsi="http://www.w3.org/2001/ XMLSch...
<row>
...
</row>
</mysql>

If I want to loop the row part, writing $("#textarea").html($("#textarea").html() temp) can only loop the entire content. What should I do?

我想大声告诉你我想大声告诉你2663 days ago881

reply all(2)I'll reply

  • 天蓬老师

    天蓬老师2017-07-05 10:57:06

    The fewer dom operations, the better. The best way is to loop first, then process and then insert, otherwise the performance may be greatly affected
    For example:

    var deafult = $('textarea').val();
       
    default += temp;
    
    $('textarea').val(default);
        

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-07-05 10:57:06

    Can’t you just splice it first and then insert it?

    reply
    0
  • Cancelreply