One note most people are unaware of with styles. The page applies the last style that is assigned to an object. So if you put the style #m2 {display: none; } after the javascript it will not work. Also if you are using separate javascript or CSS pages they have to load in the correct order for this to work. And you definatly can not assign the style directly to the object that is being moused over. Also the style has to be assigned via and ID tag or it will not work.
You can however apply other styles to the Object directly in HTML, via a Style Tag, or even Javascript... as long as they aren't conflicting styles. In other words... If I set the Style tag inside my Head tags, and set the text of an object to
Font-Weight: bold (using the object Class or a global TagType style)
I can also do an inline HTML style that sets the Color of the object. The inline HTML style trumps all... however, any style not explicitly declared in the inline HTML style can be set via a Class style in the Head tag/CSS Sheet, etc.
EXAMPLE:
<html>
<head>
<style>
.MyDiv {
Font-Weight: bold;
Text-Decoration: underline;
}
</style>
</head>
<body>
<div id="divMyText" class="MyDiv" style="Color: #FF0000; Text-Decoration: none">This is my text. It is Red, and Bold, but not underlined.</div>
</body>
</html>In the above example I use both a Class, and inline HTML. The inline HTML trumps the Class CSS... so the text will be Red (#FF0000), and the text will NOT be underlined. However, I didn't contradict the Class CSS of Font-Weight... so my text will also be Bold.
Final Result will look like this:
This is my text. It is Red, and Bold, but not underlined.