Reputation: 1141
I know you can use this to get all elements with the name 'target':
document.getElementsByName('target')
But what if I want to select only inputs with that name?
Upvotes: 1
Views: 123
Reputation: 1547
Since you can catch forms
by name
you can do
<form name="outerTarget">
<input type="button" value="test" name="target">
</form>
<script>
document.forms['outerTarget'].target;
</script>
Upvotes: 1
Reputation: 39777
In pure JavaScript you can use document.querySelectorAll
document.querySelectorAll('input[name="target"]');
Upvotes: 5
Reputation: 104775
You can do:
var inputs = document.querySelectorAll("input[name=target]");
Upvotes: 2