2016-05-20 24 views
0

所以基本上這對w3School工作,但不是在我的生活環境。下面是代碼:.fade不要在我的代碼上工作,但可以在w3School上使用相同的代碼正常工作。爲什麼?

<!DOCTYPE html> 
    <html lang="en"> 
    <head> 
     <meta charset="UTF-8"> 
     <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> 
     <title>Vecta Corp. Mobile</title> 
     <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" /> 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script> 
    <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> 
      <script> 
    $(document).ready(function(){ 
     $("#5").click(function(){ 
      $("#yourview").fadeTo(1000, 0.05); 
     }); 
    }); 

     </script> 
    </head> 

    <body> 
    <section data-role="content"> 

      <h2>Dr. Tint SolarPill Tint</h2> 
      <h3>See how SolarPill looks from inside your tinted car</h3> 

      <p><img alt="" src="images/tintshade.png" id="yourview" style="width:347px;"></p> 
<p style="width:350px;"> 
<input id="5" value="5%" style="font-size:12px;width: 36px;margin-left: 18px;" type="button"> 

</p> 


     </section> 
    </div> 
</body> 
</html> 

這裏是:w3school link和將此代碼粘貼到它,並嘗試自己:

<!DOCTYPE html> 
<html> 
<head> 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script> 
<script> 
$(document).ready(function(){ 
    $("#5").click(function(){ 
     $("#yourview").fadeTo(1000, 0.4); 
    }); 
}); 
</script> 
</head> 
<body> 

<p><img alt="" src="http://www.mobile-tinting.com/img.png" id="yourview" style="width:347px;"></p> 

<input id="5" value="5%" style="font-size:12px;width: 36px;margin-left: 18px;" type="button"> 
</body> 
</html> 

難道這與jQuery Mobile的衝突,因爲這是字面上的唯一區別這兩個代碼。或者我在這裏做錯了什麼?

+0

您的開發者控制檯告訴您什麼?順便說一句,嘗試一個更好的教程網站。 – Raptor

+0

適用於我..檢查您的瀏覽器'控制檯.. .. –

+0

我檢查了我的控制檯,它顯示了很好,但由於一些奇怪的原因,它只是不起作用。我的代碼對你們工作正常嗎? –

回答

0

我剛纔在Codepen上舉了幾個例子。這似乎是一個常見的問題,按鈕輸入不可點擊(這似乎是由於jQuery Mobile)。你可以嘗試一些其他的方式來實現什麼是你正在嘗試做的:

  1. 使用<button>標籤,而不是
  2. 使用<a>標籤,該data-role屬性設置爲button所以它採用的按鈕樣式。
+0

是的。就是這樣!謝謝。現在改爲按鈕及其工作。 Jquery移動似乎是越野車。 –

相關問題