How can count all input elements with has id which starting with (myInputElem) inside dom using jquery. So there will be dynamic number of input elements like
<input id="myInputElem1" type="text" value="Eleme1">
<input id="myInputElem2" type="text" value="Eleme2">
..
<input id="myInputElemx" type="text" value="Elemex">
So I just need to count them.
You can use the attribute starts with selector and then get the length
$('[id^="myInputElem"]').length
use attribute starts with selector ^
.
If you want to use the ends with selector, use $
$("[id^='myInputElem']").length;
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