0

I need to find current value of text in textarea.

Here is example code

http://jsfiddle.net/BEE6U/

<form>
    <textarea id="my_txt" cols="80" rows="10">THIS IS START TEXT.</textarea><br />
    <textarea id="my_txt2" cols="80" rows="10"></textarea><br />
    <input type="button" id="find" value="Copy">
<form>  


$(document).ready(function(){
    $('#find').click(function(){
        var text_box_text = $('#my_txt').text();
        $('#my_txt2').text(text_box_text);
    });
});

When i click "Copy" button, text friend textarea with id my_txt copied to textarea with id "my_txt2".

Problem is when i change text in textarea with id "my_txt" and click "Copy" button, it still copy default value instead of current text in textarea.

How do i get current text in the text area ?

Yujin Boby
  • 273
  • 2
  • 10
  • Using .val() as appose to .text() will help you here. Here's a great answer to the question "What's the difference between .val() and .html()" http://stackoverflow.com/questions/807867/difference-between-val-and-text – Dan Feb 22 '14 at 22:10
  • Thank you. Got it working :) – Yujin Boby Feb 22 '14 at 22:11

0 Answers0