I’d like to get all the input tags with an id.
Right now, my code is:
inputs = document.querySelectorAll('input');
for (i=0; i<inputs.length; i++) {
if (inputs[i].id) { .. }
}
I’d like something cleaner if possible.
Thanks in advance.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can look for the existence of an attribute with
[attribute name]:See the W3C docs on attribute presence selectors.