2014-11-03 1 views
0

enter image description here캐치 mousve 호버는

두 번째 테이블에 첨부 된 이미지를 보면, 강조 얻을 것이다 . 이제

enter image description here

나는 다시 설계 해요 :

///////////////////////////////////////////////////////////// 
function HightLightTable1() { 

    // 0 
    $(".t1_h_x0").hover(
function() { 
    $(this).css("background-color", "yellow"); 
    $(".t1_t_x0").css("background-color", "yellow"); 
}, function() { 
    $(this).css("background-color", "white"); 
    $(".t1_t_x0").css("background-color", "white"); 
} 
); 

    // 1 
    $(".t1_h_x1").hover(
function() { 
    $(this).css("background-color", "yellow"); 
    $(".t1_t_x1").css("background-color", "yellow"); 
}, function() { 
    $(this).css("background-color", "white"); 
    $(".t1_t_x1").css("background-color", "white"); 
} 
); 
// and keep adding code here if there are more tables 
} 

이, 예를 들어, 또한 HTML 코드 많이로 첫 번째 테이블을 이끌 것입니다 :이 사용 hover 기능을 acheive 관리 사이트를 방문하고 궁금해지기 위해 더 효율적인 방법이 있습니까? 에

링크 내 site 당신이보고 싶을 경우

답변

0

당신은 같은 클래스 이름을 공중 선회하는 모든 셀을 제공하여 코드를 단순화하고 권리를 ADRESS하는 쿼리를 작성하기 위해 세포의 텍스트를 사용할 수 있습니다 이 같은 걸쳐 :

$(".hovercell").hover(
    function() { 
     $(this).css("background-color", "yellow"); 
     $(".t1_t_x"+$(this).text()).css("background-color", "yellow"); 
    }, function() { 
     $(this).css("background-color", "white"); 
     $(".t1_t_x"+$(this).text()).css("background-color", "white"); 
    } 
); 

jsfiddle : http://jsfiddle.net/markai/o3arj251/