开发者

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜