var str=$('#textarea_dtl').val();
Here we stored the text box data in a variable str. <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>
<textarea class='form-control' rows=2
name=textarea_dtl id=textarea_dtl></textarea>
<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>
$("#textarea_dt13").prop("disabled", false);
Here the button with id b5 on Click will disable the textarea , same time button with id b6 will enable it by using click event function.
<input type=text name=my_text id=t2>
<button name=b5 id=b5>Disable</button> <button name=b6 id=b6>Enable</button>
JQuery
<script>
$(document).ready(function() {
$("#b5").click(function(){
$("#textarea_dt13").prop("disabled", true);
})
$("#b6").click(function(){
$("#textarea_dt13").prop("disabled", false);
})
})
</script>
var str=$('#t1').val();
$('#d1').html(str.length);
Reading the number of Chars in a Textarea
<textarea name=t123 rows=4 cols=60 id=t123></textarea>
<button id=b123>Send Data</button>
<div id=d123>0</div>
Jquery
<script>
$(document).ready(function() {
$('#b123' ).prop( 'disabled',true )
// Jquery code here ///
$('#t123').attr('maxlength','50')
$('#t123').keyup(function(){
var str=$('#t123').val();
$('#d123').html(str.length);
if(str.length>9){$('#b123' ).prop( 'disabled',false )}
else{$('#b123' ).prop( 'disabled',true)}
})
////
});
</script>
To add colour changes to button use css function.
$('#b123').css('background','#ecf0eb')
TextBoxMost Popular JQuery Scripts | |
1 | Two dependant list boxes |
2 | Calendar with Date Selection |
3 | Data change by Slider |
4 | Show & Hide element |