Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing style of a <a> tag in the declaration itself?

Status
Not open for further replies.

JulianUK

Programmer
Apr 17, 2002
73
GB
Hi
I have a feeling this is a tedious question to some but I haven't been able to find my answer in the archives - for that I apologise.

Can I change the style of a link (in my case, simply the colour on hover) in the actual <a> declaration and not in a prior <style> declaration?

something like...
<a style=&quot;{hover: #FF0000}&quot; href=&quot; etc.

Can't work the syntax for it.

Thanks in advance, Julian
 
Hi Julian,

You can use some javascript:

<html>
<head>
<title></title>
<script language=&quot;javascript&quot;>
function changeLink(myself)
{
var ms = myself.style
ms.color = 'red'
ms.backgroundColor = 'yellow'
ms.textDecoration = 'none'
}

function changBack(myself)
{
var ms = myself.style
ms.color = ''
ms.backgroundColor = ''
ms.textDecoration = ''
}
</script>
</head>

<body>
<a onmouseover=&quot;changeLink(this)&quot; onmouseout=&quot;changBack(this)&quot; href=&quot;your.asp&quot;>to your page</a><br>
</body>
</html>

Hope this helps,
Erik <!-- My sport: Boomerang throwing !!
This year I will participate at the World Championships in Germany. (!! Many Happy Returns !! -->
 
Thanks Boomerang

I thought that I might be able to do it simply, but yes, I could achieve it that way. Thats an acceptable solution, thanks.

Like the boomerang site! do you stand a chance of winning?!

Julian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top