Solved

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

Posted on 2006-06-25
6
1,773 Views
Last Modified: 2012-06-22
How can I do something like:

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

eg.
<div class="foo">bar</div>
0
Comment
Question by:mnb93
  • 2
6 Comments
 
LVL 6

Expert Comment

by:pD_EO
Comment Utility
Changing the class?

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

document.getElementById("foo").className = "yar";
0
 
LVL 15

Accepted Solution

by:
justinbillig earned 250 total points
Comment Utility
I think what your looking for is here in this link


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


0
 
LVL 4

Expert Comment

by:FSIFM
Comment Utility
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
 
LVL 15

Expert Comment

by:justinbillig
Comment Utility
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

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now