0

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>

j08691
  • 204,283
  • 31
  • 260
  • 272
user3396295
  • 35
  • 1
  • 1
  • 7
  • 1
    possible duplicate of [How to get the value of a selected radio button using its name in jQuery?](http://stackoverflow.com/questions/986120/how-to-get-the-value-of-a-selected-radio-button-using-its-name-in-jquery) – Tomasz Kowalczyk Apr 16 '14 at 19:00

1 Answers1

15

You can do that with attribute selector:

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

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

juvian
  • 15,875
  • 2
  • 37
  • 38