Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript hover one element to change text color of another

I feel that I am getting close but am new to javascript. Is there anything wrong with this code. I want when you hover on element "research_arrow" to change the text color of "research_link".

$(document).ready(function () {
  $(".research_arrow").hover(function () {
    $(".research_link").css("color:#ffffff");
  });
  $(".research_arrow").mouseleave(function () {
     $(".research_link").css("color:#000000");
  });
});
like image 531
Michael Avatar asked Mar 19 '14 18:03

Michael


2 Answers

You're using object notation, in which case, you need {}

css({color:"#ffffff"});

Or if you just want to set one property:

css("color", "#ffffff");
like image 188
tymeJV Avatar answered Nov 02 '22 16:11

tymeJV


Try this,

$(document).ready(function(){
  $(".research_arrow").hover(function() {
     $(".research_link").css("color", "#ffffff");
  }, function() {
     $(".research_link").css("color", "#000000");
  });
});

hover accepts two function one like mouseover and other like mouse out.

like image 37
Remya Murali Avatar answered Nov 02 '22 17:11

Remya Murali