user3396295
user3396295

Reputation: 35

Get textarea by name attribute

If I want to get field data by ID I will user: var contentText = $("#contentText").val();

How do I get field data by field name?

i.e.: <textarea name="contentText"></textarea>

Upvotes: 0

Views: 11457

Answers (1)

juvian
juvian

Reputation: 16068

You can do that with attribute selector:

 $("textarea[name='contentText']")

You can read more about it here: https://api.jquery.com/attribute-equals-selector/

Upvotes: 15

Related Questions