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?
在纯JavaScript中,您可以使用document.querySelectorAll
document.querySelectorAll('input[name="target"]');
你可以做:
var inputs = document.querySelectorAll("input[name=target]");
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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.