Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

changing display of multiple div classes with javascript

I'm fairly new to this whole web development stuff, but does anyone know how I can change the display of a div class with javascript?

For example...

Code:
 

<div class="monkey">

Some random text.

</div>

 

<div class="monkey">

Some more random text.

</div>

 

<div class="monkey">

Even more random text.

</div>

 

I want to be able to say something like:

Code:
monkey.style.display="none"

Is there any way to do this? I've looked all over online but I can't figure anything out. I do know how to access individual divs from their ID, but in this case I have a whole set of divs that I want to change all at once, not one at a time.
 

Davey

Member

You might want to try jQuery, a javascript framework. Here you can find a series of 15 video tutorials for beginners. Probably the first video tutorial is enough to do what you want to do, and even has a nice fadeout animation. ^_^
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top