javascript - Populate input field using jQuery - Stack Overflow

I have a span on my page containing text, on page load, is it possible to populate an input field with

I have a span on my page containing text, on page load, is it possible to populate an input field with this inner html using jQuery?

I've tried to setup a fiddle with my attempt only its not working...

/

I have a span on my page containing text, on page load, is it possible to populate an input field with this inner html using jQuery?

I've tried to setup a fiddle with my attempt only its not working...

http://jsfiddle/tQkaZ/

Share Improve this question asked Apr 20, 2012 at 10:05 LiamLiam 9,86340 gold badges114 silver badges214 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 2

You just missed the . off your first class selector. Here's an updated working fiddle.

$('hiddenfield').val( //Missing .
    $('.prodheader').html()
);​

the way you tried is correct. you just forgot to add the dot[.] before class name

$('.hiddenfield').val(
    $('.prodheader').html()
);

http://jsfiddle/tQkaZ/5/

You just forgot the class symbol in the selector. Here's the fix:

http://jsfiddle/tQkaZ/2/

$('.hiddenfield').val(
    $('.prodheader').html()
);​

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745649853a4638196.html

相关推荐

  • javascript - Populate input field using jQuery - Stack Overflow

    I have a span on my page containing text, on page load, is it possible to populate an input field with

    22天前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信