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
  • 197,815
  • 30
  • 248
  • 265
user3396295
  • 35
  • 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

14

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,610
  • 2
  • 34
  • 36