Link to home
Start Free TrialLog in
Avatar of pingeyeg
pingeyeg

asked on

Loop to find ul tag with correct id

I'm working on building a script that will loop through all ul's on the page and grab the one with the correct id, but am having slight difficulties.  Any thoughts:

var ul = document.getElementsByTagName("ul");
var polite = ["input1", "input2", "input3"];
for(var u=0; u<ul.length; u++) {
	for(var p=0; p<ul.attributes.length; p++) {
		if(ul[p].getAttribute("id") == polite[p]) {
			polite = ul[p];
		}
	}
}
console.log(polite);
var politeLoads = polite.getElementsByTagName("input");

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial