0

Can someone tell how to have a button chnage colour on selection. and change back once another link is selected. I have tried using

::selection selector in css (but this is not compatible in ie)

Thanks

Jonathan

2
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by jcomputing
0

Have you explored using JavaScript as an option?

document.getElementById("id").style.backgroundColor="value"
0

Here is a more complete example that you can play around with:

<html>
<head>
<script type="text/javascript">
 function chgBtn()
 {
   document.getElementById("btn").style.backgroundColor="red";
 }
</script>
</head>
<body>

  <button id="btn" type="button" onclick="chgBtn()">Set background color</button>

</body>
</html>
0

Thanks for your swift reply. This works great but once I click on the button this stays red even if i click on a different link.

I would like the button to change colour on selection but if i was to select a different link or any other part of the page. I would like the button to change to its original colour.

0

Sorry, missed the part about the color changing back when you click on another link. Hmmm. I need to get back to you on this one.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.