Changing and image to a text field.

J

JB

I have a set of links that are currently images that when the person rolls
over them, they change color. Essentially the image is a box where the
background is brown and the text is blue. When the person rolls over it,
they want it blue background with brown text. As I said we currently do
images but that is annoying.

Is there an easy way ( or at least relatively easy ) way to do this just
using text and javascript to change the colors?

TIA - Jeff.
 
G

Guest

Howdy,

Yes, it's quite simple. Here is a rough example that should give you an idea
where to go:

<style type="text/css">
..MouseOut
{
border: solid 1px black;
background-color: orange;
color: blue;
}
..MouseOver
{
border: solid 1px red;
background-color: brown;
color: white;
}
</style>
<asp:HyperLink runat="server" ID="myLink" CssClass="MouseOut"
onmouseover="ChangeApperance(this, true)"
onmouseout="ChangeApperance(this, false)" Text="Click me!" NavigateUrl="#" />

<script type="text/javascript">

function ChangeApperance(anchor, isMouseOver)
{
if (anchor)
{
anchor.className = isMouseOver ? 'MouseOver' : 'MouseOut';
}
}

</script>

Please note your requirement is a perfect subject to build a web server
control inheriting from hyperlink.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top