How to populate a textarea(say id1) when user types in a different textarea(say id2) using php and javascript
I have 2 textarea html elements say id1 and id2. When I type in id1 the content of id1 should also be displayed in id2.
Can anyone suggest me php code or jquery plugin or javascript to complete this process ?T开发者_如何学Chanking in Advance
GirishSimple way how to do it:
$(document).ready(function(){
$('.tb1').keyup(function(){
var content = $('.tb1').val();
$('.tb2').val(content);
});
});
And HTML:
<textarea name="Text1" class="tb1" ></textarea>
<textarea name="Text2" class="tb2" ></textarea>
Working example at jsfiddle.net.
like this
the html
<input type="text" id="box_1" />
<input type="text" id="box_2" />
the jQuery
$("#box_1").change(function(){
$('#box_2').val( $(this).val() );
});
with jQuery: http://jsfiddle.net/EjmtY/
HTML:
<textarea id='id1'></textarea>
<textarea id='id2'></textarea>
JavaScript:
$('#id1').keyup(function(){
$('#id2').val($(this).val())
})
精彩评论