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 badges3 Answers
Reset to default 2You 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()
);