Copying text from an element in jquery and inseting into another elelement
开发者_如何转开发I am trying to create a simple js script that will copy text from a specified div element and paste it into the 'value' field of a form. This is the best I have managed to come up with:
var txt=$('div').clone();
$('#name').val(txt);
Can somebody please let me know where I am going wrong?
Thanks guys!
var txt=$('div .someclassname').text();
or var txt=$('div #someidname').text();
$('#name').val(txt);
it like that.
精彩评论