How can I use onmouseover to change text color

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Provision
    New Member
    • Mar 2014
    • 5

    #16
    You're looking at this in too much of a complex angle, it's just simple and you don't need so much code.

    Comment

    • Provision
      New Member
      • Mar 2014
      • 5

      #17
      Code:
      <script>
      function turnRed(x)
      {
      unitedBrokers.style.color ="#ff0000";
      }
      </script>
      <script>
      function turnGrey(x)
      {
      unitedBrokers.style.color ="#808080";
      }
      </script>
      
      <a id="unitedBrokers" onmouseover="turnRed()" onmouseout="turnGrey()" style="text-decoration: none">United Brokers Incorporated</a>
      I've just tested this and it works
      Last edited by acoder; Apr 25 '14, 12:31 AM.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #18
        still, the CSS solution doesn‘t even require JS:
        Code:
        <a class="color-swap">…</a>
        Code:
        .color-swap {
          color: #888;
        }
        .color-swap:hover {
          color: #f00;
        }

        Comment

        • Provision
          New Member
          • Mar 2014
          • 5

          #19
          It still works, like he planned

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #20
            even after 5 years …

            Comment

            Working...