2010-06-21 41 views
0

我使用此代碼,它是工作在所有的瀏覽器沒有故障,但與IE它`不工作任何人都可以幫我這個JQuery的。每()和IE所有版本問題

$('a.download').each(function() { 
    $(this).colorbox({href:$(this).attr('href') + ' div#download_popup',onComplete: function(){ 
    $('div.sociable').hide(); 
    $('a#share_button').click(function(){ 
     $('div.sociable').slideToggle().show(); 

    }); 

}})}); 
+7

定義「不工作」。什麼是「不工作」? – CaffGeek 2010-06-21 20:21:50

+0

colorbox開始加載然後沒有任何反應只有覆蓋是有 – ahmedelgabri 2010-06-21 20:29:09

回答

0
所有版本
$('a.download').each(function() { 
    $(this).colorbox({ 
     href:$(this).attr('href') + ' div#download_popup', 
     onComplete: function() { 
      $('div.sociable').hide(); 
      $('a#share_button').click(function() { 
       $('div.sociable').slideToggle().show(); 
      }); 
     } 
    }) // - missing semicolon goes here 
}); 

您缺少分號。

+0

我試過了,但它沒有解決問題 – ahmedelgabri 2010-06-21 20:29:33

+0

因爲我不能看到你的HTML,我不知道最新情況正在發生,但我的猜測是,有東西與href錯誤。你想要拉到那裏?在#之前嘗試沒有空格和/或沒有div。 – realshadow 2010-06-21 20:40:10

+0

我試着在colorbox里加載一個外部div,如果href是錯誤的,就我所知,它在其他瀏覽器中不能工作? – ahmedelgabri 2010-06-21 20:53:12

1

清理代碼(稍好無論如何),它看起來像它缺少一個分號

$('a.download') 
    .each(function() { 
     $(this).colorbox({ 
      href: $(this).attr('href') + ' div#download_popup', 
      onComplete: function() { 
       $('div.sociable').hide(); 
       $('a#share_button').click(function() { 
        $('div.sociable').slideToggle().show(); 
       }); 
      } 
     }); // RIGHT HERE 
    }); 
+0

添加一些警報聲明,看看事情是否你期望的。 ($('a#share_button').length);'和'alert($('div.sociable')。length);'並且在onComplete函數中放置一個警告以確保它是被解僱。 – CaffGeek 2010-06-21 21:36:53

1
$('a.download').each(function() 
{ 
    $(this).colorbox(
    { 
     href: $(this).attr("href") + ' div#download_popup', 
     onComplete: function() 
     { 
      $('div.sociable').hide(); 
      $('a#share_button').click(function() 
      { 
       $('div.sociable').slideToggle().show(); 
      }); 
     } 
    }); 
}); 

當你對齊的代碼塊垂直,更容易看到缺少大括號,括號,或分號。