admin管理员组

文章数量:1244432

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>

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>

Share Improve this question edited Apr 16, 2014 at 19:00 j08691 208k32 gold badges269 silver badges280 bronze badges asked Apr 16, 2014 at 18:57 user3396295user3396295 351 gold badge1 silver badge7 bronze badges 1
  • 1 possible duplicate of How to get the value of a selected radio button using its name in jQuery? – Tomasz Kowalczyk Commented Apr 16, 2014 at 19:00
Add a ment  | 

1 Answer 1

Reset to default 15

You can do that with attribute selector:

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

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

本文标签: javascriptGet textarea by name attributeStack Overflow