.fade没有处理我的代码,但在w3School上使用相同的代码可以正常工作。为什么?

时间:2016-05-20 07:35:52

标签: jquery mobile fadeto

所以基本上这适用于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的冲突,因为这实际上是两个代码之间的唯一区别。或者我在这里做错了什么?

1 个答案:

答案 0 :(得分:0)

我刚刚就此Codepen做了几个例子。按钮输入无法点击似乎是一个常见问题(似乎是由于jQuery Mobile)。您可以尝试其他一些方法来实现您的目标:

  1. 使用<button>代码
  2. 使用<a>代码,将data-role属性设置为button,使其采用按钮样式。
相关问题