javascript - Populate input field using jQuery - Stack Overflow

admin2025-04-26  17

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()
);​
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745649854a312103.html

最新回复(0)