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>
- 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
1 Answer
Reset to default 15You can do that with attribute selector:
$("textarea[name='contentText']")
You can read more about it here: https://api.jquery./attribute-equals-selector/