• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1787
  • Last Modified:

document.getElementById('foo').style.display = 'none'; FOR classes

How can I do something like:

document.getElementById('foo').style.display = 'none';
but for classes:

eg.
<div class="foo">bar</div>
0
mnb93
Asked:
mnb93
  • 2
1 Solution
 
pD_EOCommented:
Changing the class?

<div class="foo" id="foo">bar</div>

document.getElementById("foo").className = "yar";
0
 
justinbilligCommented:
I think what your looking for is here in this link


http://www.faqts.com/knowledge_base/view.phtml/aid/2147/fid/128


0
 
James GlenIT EngineerCommented:
why dont you just assign id="foo" to the <div> tag.
e.g.  <div id="foo">bar</div>

Instead of a class as classes are used for CSS.
0
 
justinbilligCommented:
well what I think he is trying to accomplish is .. there are multiple items that use the foo class, what he wants to do is programatically hide all items that have the foo class without having to iterate though all the items on the page
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now