...

View Full Version : OnMouseOver- button color change-



iota
01-28-2005, 06:10 AM
Hi master,

Let me know a correct coding of OnMouseOver and OnMouseOut button color change.
Thank you so much.

Brandoe85
01-28-2005, 06:27 AM
Heres something really simple:


<html>
<head>
<style type="text/css">
#button1 {
color:red;
background:white;
}
#button2 {
color:white;
background:red;
}
</style>
</head>
<body>
<form>
<input type="button" id="button1" value="Button" onmouseover="document.forms[0].button1.id='button2'" onmouseout="document.forms[0].button1.id='button1'"><br><br>
<input type="button" id="button2" value="Button" onmouseover="document.forms[0].button2.id='button1'" onmouseout="document.forms[0].button2.id='button2'"><br><br>
</form>
</body>
</html>

Mhtml
01-28-2005, 06:29 AM
<input type="submit" onmouseover="this.style.background='red'" onmouseover="this.style.background=''"/>


Of course you could also just use CSS:


input:hover {
background: red;
}
But that isn't going to work in all browsers.

[edit:] I don't think that changing the id is such a good idea, changing the class maybe but not the id. What if you are running another script using the id? They might behave incorrectly. However I am definitely not a JS guru.

iota
01-28-2005, 06:33 AM
I would like to know the Current Javascript Version.
Microsoft Window SP2 said IE support JS version 1.3
I've heard of Javascript Version 1.5
Thanks again.

Brandoe85
01-28-2005, 06:49 AM
[edit:] I don't think that changing the id is such a good idea, changing the class maybe but not the id. What if you are running another script using the id? They might behave incorrectly. However I am definitely not a JS guru.
Err I think your right. I obviously wasn't thinking completley when I posted it. Good eye. :o



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum