如何在textarea中的每一行复制文本
<!--
first, im gonna paste my text in input like this..
<textarea id="input">
one
two
three
four
five
six
seven
(and so on...)
</textarea>
duplicating text is depend on break line..
and the result is like this..
Result:
one
one
two
two
two
two
two
two
two
three
three
four
four
four
five
five
five
five
six
six
six
seven
seven
seven
seven
-->
here is my code:
<textarea id="input" style="width:100%; height:100px;" placeholder="input" ></textarea>
<textarea id="output" style="width:100%; height:100px;" placeholder="output" ></textarea>
<input id="process" type="button" value="Process!" />
&#13;
谢谢你提前
答案 0 :(得分:0)
试试这个,它会复制每一行的文字..
$(':button').click(function(){
var invalue = $('#input').val();
$('#output').val(invalue.replace(/^(.*)$/gm, '$1\n$1'))
})