I have a large string in a variable that includes a whole bunch of HTML tags.
I want to get the value of a hidden input field within the string and store it in its own var.
<input type="hidden" value="WantThis" />
Can anyone help me out at all?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can parse the HTML with jQuery to get the value:
I’m assuming the hidden field has a name. If it doesn’t, you’ll need to specify
input[type=hidden]and find it using its position relative to the rest of the content.If your string does not already have a root element and the
<input>is not nested, you’ll probably want to use$('<div>' + myString + '</div>')instead.