hankknight
asked on
Display none for all links inside div
Using JavaScript I want to make all links inside <div id="foobar"> display: none
var els = document.getElementsByTagName("a");
for (var i=0; i<els.length; i++) {
if (els[i].parentNode____has_id___submenu {
els[i].display.none;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I know that!
What I don't know if how to test if the parent id = foobar
I need this line fixed:
if (els[i].parentNode____has_ id___subme nu {
What I don't know if how to test if the parent id = foobar
I need this line fixed:
if (els[i].parentNode____has_
why do you need to test that?
if you get the foobar element by id. then get all of the link elements which are descendants of that, there is no need to test for that condition since you already know they are descendants of the foobar element.
if you get the foobar element by id. then get all of the link elements which are descendants of that, there is no need to test for that condition since you already know they are descendants of the foobar element.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hank, thanks for the grade & points, but I think that alien109 deserves them because he did the referenced update.
Please "request assistance" with this question, and give alien109 all the points.
Thanks
Please "request assistance" with this question, and give alien109 all the points.
Thanks
Thanks Hank for taking the time, and making the effort to reward alien109.
Thanks for the assist, and the points.
Good luck & have a great day.
Thanks for the assist, and the points.
Good luck & have a great day.
els[i].stye.display = "none";