View Full Version : Change Background Image of an Anchor?
darkoZiac
04-17-2005, 09:58 PM
Is there a script that can be used to change the backgroundImage / style of an anchor (just as the title says).
coothead
04-18-2005, 10:23 AM
Hi there darkoZiac,
here is a working example that uses CSS rather than javascript...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>anchor rollover</title>
<base href="http://coothead.homestead.com/files/"/>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<style type="text/css">
/*<![CDATA[*/
#container {
width:100px;
border:3px double #666;
margin:20px auto;
}
a#link {
display:block;
width:100px;
height:100px;
background-image:url('anim1.gif');
}
a#link:hover {
background-image:url('anim2.gif');
}
/*//]]>*/
</style>
</head>
<body>
<div id="container">
<a id="link" href="http://www.codingforums.com/"></a>
</div>
</body>
</html>
coothead
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.