2012-01-10 38 views
0

我有一個jQuery我在一個網站上使用,因爲在第一個函數後有一個逗號,所以在IE中打破了這一點。我不是jQuery專家,而且這些代碼可能有點隨意寫入。有沒有一種方法可以重寫這個來刪除逗號並獲得IE功能?逗號分割IE中的JQuery

$("#d1").hoverIntent(
     function() { 
     $("#c2,#c3,#c4,#c5,#c6,#c7,#c8,#c9,#c10").hide(); 
     $("#num2,#num3,#num4,#num5,#num6,#num7,#num8,#num9,#num10").hide(); 
     $("#c1").stop(true).fadeIn("slow"); 
     $("#prompt").stop(true).fadeOut("slow"); 
     $("#numStar").stop(true).fadeOut("slow"); 
     $("#num1").stop(true).fadeIn("slow"); 
     }, 
     function() { 
     } 
    ); 
+0

它是如何突破的? – 2012-01-10 20:24:24

+0

懸停沒有任何反應 – josephndenton 2012-01-10 20:24:53

+0

您的代碼有效。你爲什麼要刪除逗號?這會導致代碼不能在任何瀏覽器中運行。 – 2012-01-10 20:25:13

回答

1

參見http://cherne.net/brian/resources/jquery.hoverIntent.html。看看var config = ...

$("#d1").hoverIntent({ 
    over: 
    function() { 
     $("#c2,#c3,#c4,#c5,#c6,#c7,#c8,#c9,#c10").hide(); 
     $("#num2,#num3,#num4,#num5,#num6,#num7,#num8,#num9,#num10").hide(); 
     $("#c1").stop(true).fadeIn("slow"); 
     $("#prompt").stop(true).fadeOut("slow"); 
     $("#numStar").stop(true).fadeOut("slow"); 
     $("#num1").stop(true).fadeIn("slow"); 
    }, 
    out: function() { } 
}); 
+0

在同一頁面上,它使用與josephndenton使用它相同的方式顯示示例代碼。這只是一種替代語法。 – 2012-01-10 20:34:20

+0

也許是一個IE瀏覽器的JavaScript問題,可能與空函數有關。我不知道會發生什麼,如果不是'{}'寫'{return 42; }'。但沒關係,也許'id = d1'出現兩次或不是一個適當的元素。 – 2012-01-10 20:45:49