If you follow requinix's advice and make the constructor private in the first code sample it's a textbook example of the Singleton pattern. While there was a period a few years ago that people railed against using Singletons, the furor seems to have died down recently. In my experience, 90 percent of the time it's perfect for things like setting up database connections.
Give all the divs a class of "mydiv". Then in the <style> section change
#mydiv {
display: none;
}
to
.mydiv {
display: none;
}
then they all start off hidden.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.