2015-03-12 2 views
-1

Как копирование текста каждую строку в текстовое полеКак копирование текста каждую строку в текстовое поле

<!-- 
 
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!" />

Спасибо заранее

+0

вопрос, какой результат вам нужен ?, какая проблема y ou стоят? – Sarath

+0

извините im new здесь, мой вопрос: как дублировать текст в каждой строке в textarea –

ответ

0

попробовать это, он дублирует текст в каждой строке. .

$(':button').click(function(){ 
    var invalue = $('#input').val(); 
    $('#output').val(invalue.replace(/^(.*)$/gm, '$1\n$1')) 
}) 
+0

Привет @Sarath спасибо за ответ, но дубликаты кода зависят от $ 1. Я хочу дублировать, зависит от линии разрыва. см. мой пример http://jsfiddle.net/8ur8aL3o/ –

Смежные вопросы