Jump to content

[SOLVED] change background onmouse over


rascle

Recommended Posts

Hi

I want to create something that has some text(a link) and when you hover over the text the background colour changes and some text appears underneath original text. When you move the mouse off the link then the background colour goes back to normal and the text that appeared disappears.

Does anyone know how i would do this

or can anyone give me a link to any tutorials.

Thanks :)

Link to comment
Share on other sites

I couldnt find anything on google for when you hover over the object that the text appears, can anyone help me their?

And i am using this to change the colour of the background (div):

 

<html>

<head>

<script language="JavaScript">

<!--

 

var backColor = new Array();

backColor[0] = '#666666';

backColor[1] = '#000000';

function changeBG(whichColor){

document.all.rhys.style.backgroundColor = backColor[whichColor];

}

 

//-->

</script>

</head>

<body>

 

<div id="rhys" style="background-color: #000000;">

<a href="#" onMouseOver="javascript:changeBG(0)" onmouseout="javascript:changeBG(1)">Change</a>

 

</div>

</body>

</html>

Link to comment
Share on other sites

<html>
<head>
<script language="JavaScript">
<!--

var backColor = new Array();
backColor[0] = '#666666';
backColor[1] = '#000000';

function changeBG(whichColor){

document.all.rhys.style.backgroundColor = backColor[whichColor];

if (whichColor==0){
	document.getElementById('extra').style.display='block';
	}else{
		document.getElementById('extra').style.display='none';
		}

}

//-->
</script>
</head>
<body>

<div id="rhys" style="background-color: #000000;">
<a href="#" onMouseOver="javascript:changeBG(0)" onmouseout="javascript:changeBG(1)">Change</a>

<div id="extra" style="display:none;">
HIDDEN TEXT!
</div>
</div>
</body>
</html>

 

prolly not the most elegant, but it works :D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.