class name acess?

Discussion in 'Javascript' started by Sergio del Amo Caballero, Oct 23, 2003.

  1. I want to access div elemnent and make them visible or invisible with a
    condition. They belong to a particular class or not. I was reading the
    newsgroup old posting about classname acess and some links and i arrived
    to the conclusion that i can not access class Name with Mozilla. With
    Explorer i can acesss with document.all.className but i want visualize
    my web site in Opera 7.2, Mozilla 1.4 and Explorer 6.0. My code will be
    something like this:

    if(document.getElementsByTagName("div").className == "node1")
    document.getElementsByTagName("div").style.display="none";


    I know that the line in the if is in correct. Anybody know how to
    implent this to work in the browsers above.
     
    Sergio del Amo Caballero, Oct 23, 2003
    #1
    1. Advertising

  2. Sergio del Amo Caballero <> writes:

    > I want to access div elemnent and make them visible or invisible with
    > a condition. They belong to a particular class or not.


    > if(document.getElementsByTagName("div").className == "node1")
    > document.getElementsByTagName("div").style.display="none";


    What is "i"?

    If I understand the problem correctly, and I am not sure I do, you will
    need something like this:

    var divs = document.getElementsByTagName("div");
    for (var i=0 ; i<divs.length ; i++) {
    if (divs.className == "node1") {
    divs.style.display = "none";
    }
    }

    > I know that the line in the if is in correct. Anybody know how to
    > implent this to work in the browsers above.


    It should work in the above browsers.

    /L
    --
    Lasse Reichstein Nielsen -
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
    'Faith without judgement merely degrades the spirit divine.'
     
    Lasse Reichstein Nielsen, Oct 23, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Z2F1cmF2?=

    Uploading Data From MS Acess 2000 ti SQL server 2000

    =?Utf-8?B?Z2F1cmF2?=, Jan 9, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    816
    Mary Chipman [MSFT]
    Jan 9, 2006
  2. Rajesh R.
    Replies:
    1
    Views:
    1,643
    Bob Barrows
    Jan 9, 2004
  3. =?Utf-8?B?Sm9yZGk=?=

    ODBC data acess and asp.Net applications.

    =?Utf-8?B?Sm9yZGk=?=, Jun 10, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,716
    Kevin Spencer
    Jun 10, 2004
  4. Fabiano

    Saving at a restrict acess directory

    Fabiano, May 18, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    411
    Tarren
    May 18, 2005
  5. James
    Replies:
    2
    Views:
    381
    James
    Apr 29, 2005
Loading...

Share This Page