Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Display none for all links inside div

Posted on 2009-05-07
8
Medium Priority
?
212 Views
Last Modified: 2012-05-06
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;
    }
}

Open in new window

0
Comment
Question by:hankknight
  • 3
  • 3
7 Comments
 
LVL 12

Expert Comment

by:alien109
ID: 24329219
try

 els[i].stye.display = "none";
0
 
LVL 12

Accepted Solution

by:
alien109 earned 1800 total points
ID: 24329247
var div = document.getElementById("foobar");
var els = div.getElementsByTagName("a");
for (var i=0; i<els.length; i++) {
    els[i].stye.display = "none";
}
0
 
LVL 16

Author Comment

by:hankknight
ID: 24329255
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___submenu {
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Expert Comment

by:alien109
ID: 24329304
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.
0
 
LVL 41

Assisted Solution

by:HonorGod
HonorGod earned 200 total points
ID: 24329683
Hank,
  Take another look at the code in http://#a24329247, the first lookup finds the "foobar" div.  The next only locates anchor tags within this div.
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 24366695
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
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 24368125
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.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question