开发者

Copying text from an element in jquery and inseting into another elelement

开发者 https://www.devze.com 2023-03-25 05:55 出处:网络
开发者_如何转开发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 w

开发者_如何转开发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.

0

精彩评论

暂无评论...
验证码 换一张
取 消