0

我刚刚开始使用 jQuery,遇到了一些麻烦。

有一张缩略图表,当我将鼠标悬停在其中的图片上时,我希望每个单元格都突出显示。让那部分工作。但我也希望单元格内的图片没有下划线 - 这是从样式表继承的a:hover{text-decoration:underline}。这就是我被卡住的地方,我认为我没有设置正确的东西。

我需要使用内联样式,所以我的 jQuery 看起来像:

$('[name*=thumb]').hover(
  function () {
    //as we hover over an item, change it's background, attempt to vaquish pesky underline
    $('#' + $(this).attr('id').replace('thumb', 'thumbcontainer')).css('background-color', '#cccccc'); 
    $('#' + this).css('text-decoration', 'none');  //doesn't work : (
  },
  function () {
    //fix bgs of items we're not hovering on
    $('#' + $(this).attr('id').replace('thumb', 'thumbcontainer')).css('background-color', '#ffffff'); 
  }
);

我的 HTML 看起来像这样:

<td name="thumbcontainer8" id="thumbcontainer8"><a href="#" name="thumb8" id="thumb8"><img src="..." /></a></td>
<td name="thumbcontainer9" id="thumbcontainer9"><a href="#" name="thumb9" id="thumb9"><img src="..." /></a></td>
4

2 回答 2

3

样式表中的这条规则不会起到作用吗?

a:hover img{text-decoration:none}
于 2010-12-14T18:00:16.570 回答
2

关于什么:

  $(this).css('text-decoration', 'none');
于 2010-12-14T18:01:09.897 回答