JQuery get Value Of Textarea

JQuery get Value Of Textarea

Here we will see how to get value of Textarea and set value to text area using Jquery. Text area control allows you to accepts or writes multiple lines in it.

$('#TextArea1').val( “Assigned value to text”);

Prefix the element ID with # to get element by ID. Call val function to set given text.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

    <script type="text/javascript" language="javascript">
       
    
    $(document).ready( function (){ 
    
        $("#button1").click( function(){
          
        var textValue = "This is value assigned to text area using Jquery"  ;
         
        $('#TextArea1').val( textValue );
        
         });
                        
     });
    
    </script>

HTML code

<div>
           <input id="button1" type="button" value="Click To set text area value" />
           <br />
           After button click:
           <textarea id="TextArea1" cols="20" rows="2"></textarea>
       </div>

You can also get value from TextArea by calling val method of Jquery.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

   <script type="text/javascript" language="javascript">
      
   
   $(document).ready( function (){ 
   
       $("#button1").click( function(){
         
              
      alert( $('#TextArea1').val() );
       
        });
                       
    });
   
   </script>

Tags:

Jquery Dropdown Selected ValueHow to get Jquery selected optionGet Selected Value From Dropdownlist [JQuery]Jquery Get Target Of EventJQuery Hidden Field Set ValueJQuery TextBox Value()JQuery Get Element By ID or class name or tag nameJquery Set Value Of Textbox.JQuery Get .next() ElementLearning JqueryJQuery Set Value of Textbox or Label Control In Asp.net

Author

My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in ASP.net year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.
 

I'm Satalaj.