-1

例如,我有一个等于 news1 或 news2 的链接 ID 等等!发生的情况是,如果我将鼠标悬停在链接上,它会显示如下信息

<div id="nc1">

<table>
<tr>
<td colspan="2">Nulla venenatis rhoncus libero ac interdum. </td>
</tr>
<tr> <td colspan="2">is a long established fact that a reader will be distracted by the <br>readable content of a page when looking at its layout. 
<br>The point of using Lorem Ipsum is that it has a more-or-less normal
 <br>distribution of letters, as opposed to using 'Content here, content here', <br>making it look like 
</tr>
<tr>
<td><a href="#" id="hide">Hide</a></td>
<td>Read More</td>
</tr>   
</table>
</div>

这是我的脚本

$("#news1").hover(function(){
$("#nc1").fadeIn();
});

我怎样才能循环这个链接而不使它们成为一个函数

    <td><a id="news1" href="#">Nulla venenatis rhoncus libero ac interdum.  </a></td>
</tr>
<tr>
<td>Decemeber 09,2012</td>
<td><a id="news2" href="#">Proin gravida placerat nulla, euismod consectetur mauris tincidunt a. </a></td>
</tr>
<tr>
<td>Decemeber 09,2012</td>
<td><a id="news3" href="#"> euismod consectetur mauris tincidunt a. </a></td>
</tr>
4

1 回答 1

1

像这样:

$("#news1").hover(function(){
     for (var i = 1; i < NumberOfDivs; i++){
         $("#nc"+i).fadeIn();
     }
});
于 2012-12-11T02:32:12.133 回答