I'm trying to get all input elements within a certain div, but it seems to return all inputs on any given page... is there a way to do this?
if($('#umi-form')) {
var inputs = document.getElementsByTagName('input');
}
It can be done like this:
var $inputs = $('#umi-form input');
Your if()
test will always evaluate true
. You should use the length
property in the if()
.
var uform = $('#umi-form');
if(uform.length) {
var inputs = uform.find('input');
}
If you were hoping to get a nodeList
instead of a jQuery object, do this:
var uform = $('#umi-form');
if(uform[0]) {
var inputs = uform[0].getElementsByTagName('input');
}
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