JQuery Textarea

Textarea are used to collect more line of data from users.

Reading the data entered in textarea

Our textarea id=textarea_dtl, here is the code to read the value entered inside a text box.
var str=$('#textarea_dtl').val();
Here we stored the text box data in a variable str.
We can display the data entered by connecting it to a button click function.
HTML part
<textarea rows=2 cols=30 name=textarea_dtl id=textarea_dtl></textarea> <button name=b1 id=b1>Copy</button>   <div id=d1></div> 
JQuery
<script>
$(document).ready(function() {
$("#b1").click(function(){
var str=$('#textarea_dtl').val();
$("#d1").html(str);
})
})
</script>

Adding Bootstrap Design

We will add class='form-control' to our textarea.
<textarea class='form-control' rows=2  name=textarea_dtl id=textarea_dtl></textarea>

Setting the value of a textarea

We will use val() to update or add text to our textarea.
HTML
<textarea rows=2 cols=30 name=textarea_dtl2 id=textarea_dtl2 class='form-control'></textarea> <button name=b12 id=b12>Show Data</button>
JQuery

<script>
$(document).ready(function() {
$("#b12").click(function(){
$("#textarea_dtl2").val('Default Data to be shown inside textarea');
})
})
</script>

Subscribe to our mailing list

* indicates required
Subscribe to plus2net
Your Rating


Google+

Post Comment This is for short comments only. Use the forum for more discussions.




Subscribe to our mailing list

* indicates required
Subscribe to plus2net



Most Popular JQuery Scripts

1

Two dependant list boxes

2

Calendar with Date Selection

3

Data change by Slider

4

Show & Hide element
HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us
©2000-2018 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer