0

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.net/tQkaZ/

3 Answers 3

2

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

$('hiddenfield').val( //Missing .
    $('.prodheader').html()
);​
Sign up to request clarification or add additional context in comments.

1 Comment

@user766266 - No problem, it's easy to miss the obvious sometimes!
0

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

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

http://jsfiddle.net/tQkaZ/5/

Comments

0

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

http://jsfiddle.net/tQkaZ/2/

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.