Making one link change color when moused over

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Making one link change color when moused over

Post by nigma »

Hey lets say I have 10 links on site. When someone mouses over one I want just that ones text to change blue ( note: not the other links, just the one moused over).

Anyone know how I can do this?

Thanks for all help and advice provided.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

now this is a client-side question ;)
css defines a pseudo-class a:hover that applies to anchor-elements that have the focus

Code: Select all

<html>
	<head>
		<style type="text/css">
			a:hover &#123; color: white; background-color: blue; &#125;
		</style>
	</head>
	<body>
		<a href="javascript:void(0)">link a</a><br />
		<a href="javascript:void(0)">link b</a><br />
		<a href="javascript:void(0)">link c</a><br />
		<a href="javascript:void(0)">link d</a><br />
	</body>
</html>
bionicdonkey
Forum Contributor
Posts: 132
Joined: Fri Jan 31, 2003 2:28 am
Location: Sydney, Australia
Contact:

Post by bionicdonkey »

assign the anchor to a css class e.g

a.class:hover {
color: #0000FF;
}


then

<a class="class" href="http://www.example.com">Example</a>
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

Thanks a bunch! That worked perfectly
Post Reply