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...
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()
);
You just forgot the class symbol in the selector. Here's the fix:
$('.hiddenfield').val(
$('.prodheader').html()
);