I have some textboxes in the DOM someting like
<INPUT id=txtQuantity587117 />
<INPUT id=txtQuantity587118 />
<INPUT id=txtQuantity587119 />
<INPUT id=txtQuantity587111 />
<INPUT id=txtQuantity587112 />
The elements are all nested and are not under any particular parent node.
Is there a way to select all the input elements with id text that starts with "txtQuantity".
I want a way with javascript and not with Jquery. Thanks.
In modern browsers (and also IE8... now verified) you can use document.querySelectorAll() the attribute-starts-with selector.
var els = document.querySelectorAll("input[id^=txtQuantity]");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With