2013-12-21 40 views
-2

簡單,開始了新的接口:爲什麼這個jQuery代碼只在opera下運行,而不是在firefox和chrome下運行?

<html> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    <link rel="stylesheet" href="./style/style.css" /> 
    <script src="./javascript/jquery-1.10.2.min.js"></script> 
    <script type="text/javascript"> 
     $(document).ready(function(){ 
      var color = $('#title_buttom').css('background-color'); 
      $('.title_all').mouseover(function(){ 
       var styles = { 
       backgroundColor : '#FF0C55'}; 
       $('#title_buttom').css(styles); 
      }); 
      $('.title_all').mouseout(function(){ 
       $('#title_buttom').css('background-color',color); 
      }); 
     });​ 
    </script> 
</head> 
<body> 
    <div id='all_div'> 
     <div id='master'> 
      <div id='title_top'> 
       <div id='title_home' class='title_all'>Home</div> 
       <div id='title_info' class='title_all'>Info</div> 
       <div id='title_project' class='title_all'>Projects</div> 
       <div id='title_contectus' class='title_all'>Contect us</div> 
      </div> 
      <div id='title_buttom'></div> 
     </div> 
    </div> 

</body> 
    </html> 

爲同樣的原因,我不知道爲什麼只有Opera瀏覽器可以同時在火狐和Chrome無法使用這個代碼。這是爲什麼?

link to the css file

+0

看起來好像沒什麼問題http://jsfiddle.net/arunpjohny/9dtrd/1/ –

+0

嘗試$( 'title_all ')。在(' 鼠標移開',函數(){ $('#title_buttom ').css('background-color',color); });我添加了回答...猜這應該工作...請評論我的帖子,如果它可以正常工作 – Dwza

回答

0

試試這個

$(document).ready(function() { 
    var color = $('#title_buttom').css('background-color'); 
    $('.title_all').on('mouseover',function() { 
     var styles = { 
      backgroundColor: '#FF0C55' 
     }; 
     $('#title_buttom').css(styles); 
    }); 
    $('.title_all').on('mouseout',function() { 
     $('#title_buttom').css('background-color', color); 
    }); 
}); 

可以嘗試這個位置,以檢查是否存在使用的backgroundColor一個問題,而不是背景色在樣式對象。

$(document).ready(function() 
    { 
    var color = $('#title_buttom').css('background-color'); 

    $('.title_all').on('mouseover',function() 
     { 
      $('#title_buttom').css('background-color','#FF0C55'); 
     }); 

    $('.title_all').on('mouseout',function() 
    { 
     $('#title_buttom').css('background-color', color); 
    }); 
}); 
+0

歌劇瀏覽器可以正常使用您的添加/更改,但Firefox和Chrome瀏覽器會注意到我的代碼。 – user2387869

+0

這是acualy有點奇怪^^你用什麼jQuery版本?如果你跑小提琴(就像@Arun P Johny說的那樣),這是否仍然會發生? – Dwza

+0

我知道這有點奇怪。我使用我甚至試圖將文件夾上傳到我的真實網站和瀏覽器:firefox和chrome仍然在做這個問題,歌劇很好。嘗試與我的智能手機和其他電腦的和Firefox和鉻不顯示jQuery效果和歌劇。代碼中的某些內容是錯誤的,但我不知道是什麼。 – user2387869

相關問題