How could I get the value of a element by name instead of by ID eg if I use by id it would be $('#id').val();
views:
115answers:
2
+10
A:
Use the name attribute selector:
$("input[name=nameGoesHere]").val();
Nick Craver
2010-01-21 13:27:23
Also note that having the type of the element isn't necessary.
thenduks
2010-01-21 13:28:52
+1 for you Nick, because you were able to understand the question.
Balon
2010-01-21 13:30:26
@thenduks: While this is true...name is usually found on inputs, and this does make the selector much faster.
Nick Craver
2010-01-21 13:31:18
Fair enough, just pointing out that it works without it.
thenduks
2010-01-21 15:20:38
+8
A:
$('[name=whatever]').val()
The jQuery documentation is your friend.
thenduks
2010-01-21 13:28:16