2013-04-10 80 views
0

Fiddle link hereRemoveAttr不会删除ID?

怎么了?

$(document).ready(function(){ 
    $('.navi-ring').hover(function(){ 
      $(this).removeAttr("id"); // this doesnt work! 
     )}; 
)}; 

它并没有删除ID!它应该改变颜色,但它没有。

.navi-ring:nth-child(1):hover{ 
background-color:yellow; 

它应该remoev ID(带有边框图像),但它没有。那么圆圈应该变成黄色。

+3

你的代码中有几个语法错误,你没有在你的演示http://jsfiddle.net/hsKba/7/中加载jQuery,通常删除ID不是一个好主意。 – undefined 2013-04-10 23:21:00

+0

不要只复制/粘贴代码。自己写。如果你这样做,你会发现括号是这样的'(function(){})' – 2013-04-10 23:23:18

+0

哦,我明白为什么它现在坏了......我想隐藏ID只有当mouseenter和mouseleave时返回这个。有没有其他的选择来做到这一点? – 2013-04-10 23:23:38

回答

4

)}在它出现的两种情况下应该是})

1
$(document).ready(function(){ 
    $('.navi-ring').hover(function(){ 
     $(this).removeAttr("id"); 
    }); 
}); 

Fiddle

您还没有包括jQuery的在你的小提琴,你在你的代码有错误了Syntex。你没有正确地结束你的大括号。