2009-06-12 3 views
1

지금이 코드를 사용할 수없는 이유는 무엇입니까 마우스를 움직일 때 < tr id = '$ id'> # remove_ $ id가 표시되고 숨겨지기를 원합니다.도움말을 통해 PHP jquery 마우스

$(function() { 

var id = this.id; 

$("tr").hover(function() { 

$("#remove_" + id).show(); 

}, function() { 

$("#remove_" + id).hide(); 

}); 

}); 

PHP 코드 :이에 jQuery 코드를 변경

$result = mysql_query("SELECT * FROM wall WHERE uid='$myid' ORDER BY id DESC") or die (mysql_error()); 

while ($row = mysql_fetch_array($result)) { 

$id = $row['id']; 

$uid = $row['uid']; 

$fid = $row['fid']; 

$action = $row['action']; 


echo "< table width='467' border='0' align='left' cellpadding='0' cellspacing='0'> 

    < tr id='wall_$id'> 

    < td width='18' height='25'>&nbsp;< /td> 

    < td width='396' valign='top' class='txt'>RickStar has upload new photos. - < span class='comment'> 

< a href='#'>Comment< /a>< /span>< br />< /td> 

    < td width='53' valign='top'>< span class='txt'> 

     < div id='remove_$id' class='mydiv'>Remove< /div> 

    < /span>< /td> 

    < /tr> 

< /table>"; 


} 

답변

2

:

,691 마우스는

jQuery를 코드를 이동하는 경우

$(function() { 
    $("tr").hover(function() { 
     var id = this.id.split('_').pop(); 
     $("#remove_" + id).show(); 
    }, function() { 
     var id = this.id.split('_').pop(); 
     $("#remove_" + id).hide(); 
    }); 
}); 

그렇게해야합니다. Here's a working example if you need more help.

귀하의 코드는 두 가지 이유로 작동하지 않는 :

  • 이 호버 기능 this 외부, 너무 일찍 ID를 설정하면이 생각하는 정의되지 않았거나하지 중 하나입니다.
  • _으로 <tr>의 ID를 분할하여 실제 ID를 얻은 다음 <div>에 도착해야합니다.
0

tr가 아니라 td 위로 마우스를 이동하십시오.

+0

? ... TR 지원 : JS에서 CSS 및 마우스 오버/마우스 출력에 마우스를 올려 놓습니다. –

관련 문제