[Prototype.js] how to hide other divs?

Discussion in 'JavaScript' started by 123GoToAndPlay, Oct 24, 2007.

  1. #1
    Here's how i show a particular div

    
    var ourDiv = $(\'div-\'+randomID);
    ourDiv.show();
    
    Code (markup):
    But how do i hide the other div's?

    $('') is prototype's equivalent for document.getelementbyid
     
    123GoToAndPlay, Oct 24, 2007 IP
  2. 123GoToAndPlay

    123GoToAndPlay Peon

    Messages:
    669
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Thinking out loud:
    Do i need to make my div id into an array, perhaps?
     
    123GoToAndPlay, Oct 24, 2007 IP
  3. huenemeca

    huenemeca Peon

    Messages:
    142
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I would first hide all the divs then do your code to make the one random div visible.

    Yeah, an array of div ids would work. Go through it and set them all hidden.
     
    huenemeca, Oct 24, 2007 IP
  4. 123GoToAndPlay

    123GoToAndPlay Peon

    Messages:
    669
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hi, i already set the div's visible = hide on initialise.

    But as soon as one div is visible and i click another div, i don't now how to hide the first div again as i don't now which div-randomID was first clicked.
     
    123GoToAndPlay, Oct 24, 2007 IP