user3121571
user3121571

Reputation: 1

How to get "value" attribute from a variable?

I have a variable that holds the following value -

    $content = "<input value="" name="field" type="text">";

Using this variable in need to get the value of "value" attribute. How to get that ?

Upvotes: 0

Views: 96

Answers (2)

Somnath Kharat
Somnath Kharat

Reputation: 3600

You can also do this:

$content = '<input value="" name="field" type="text">';//replace double quotes here with single quote
$(content).val();

Jsfiddle

Upvotes: 0

Milind Anantwar
Milind Anantwar

Reputation: 82231

Dom Should be.

$content = '<input value="" name="field" type="text">';

Try This:

$(content).attr("value")

Working Fiddle

Upvotes: 3

Related Questions