SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    chown linux:users\ /world Hartmann's Avatar
    Join Date
    Aug 2000
    Location
    Houston, TX, USA
    Posts
    6,455
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)

    Getting a DIV's style by ID?

    I am trying to perform an "if" statement on a div's style definition using the following:

    Code:
    if(divName.style.display == 'block')
    {
    	divName.style.display = 'none';
    }
    My div is defined:
    Code:
    <div id="divName" style="display:block"/></div>
    However, my code is not working. On a link click the div is supposed to be hidden, yet it just stays up there. What am I doing wrong?

    Thanks!

  2. #2
    American't awestmoreland's Avatar
    Join Date
    Sep 2002
    Location
    Grand Rapids, MI
    Posts
    1,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try:
    Code:
    if(document.getElementById('divName').style.display == 'block')
    Andy
    From the English nation to a US location.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •