簡體   English   中英

查詢可在瀏覽器桌面中使用但不能在移動設備中使用的JavaScript代碼

[英]query mobile code javascript working in browser desktop but not in mobile

我的代碼有問題。 所有這些在瀏覽器桌面上都可以正常工作,但是在移動設備上,我必須單擊div #Resultat才能顯示結果。 請告訴我我的代碼有什么問題。 我輸入了一個網址,因為在jsfiddle中它可以工作,但這不是我想要的。

            <script type="text/javascript">
    $(document).delegate('#so2', 'pagebeforeshow', function(){       
    $(document).bind('click', '[data-role="controlgroup"]', function(){ 
    setTimeout(function () {displayVals(); },100);
    });
    $("#Resultat").on('click', function(event, ui) {
    displayVals();
    });
    function displayVals() {
    var so2Present = $("#so2present").val();
    var so2Voulu = $("#so2voulue").val();
    var volume = $("#volume").val();
    var unite = $("input[name='Unit']:checked").val();
    //var forme = $("input[name='Form']:checked").val();
    var summary = parseFloat(((so2Voulu - so2Present)*volume *1.5)*unite).toPrecision(3);
    $("#Resultat").html(summary); 
}
    });
</script>


<div data-role="page" id="so2">


            <div data-role="header" class="jqm-header" style="padding-top:20px; background:#4d4d4d;">
                <a href="#defaultpanel" class="navmenu-link" id="menu" style="margin-top:19px;" title="Navigation"></a>

            </div><!--/ header -->
            <div data-role="content">

<div data-role="fieldcontain">
<label for="slider" class="so2present">SO2 présent:</label></br>
    <input type="range" name="slider1" id="so2present" value="0" min="0" max="50" step="1" data-highlight="true" />
            <p></p>
        <label for="slider" class="so2voulue">SO2 voulue:</label></br>
    <input type="range" name="slider2" id="so2voulue" value="0" min="0" max="50" step="1" data-highlight="true" />
            <p></p>
        <label for="slider" class="volume">Volume:</label></br>
    <input type="range" name="slider1" id="volume" value="0" min="0" max="250" step="1" data-highlight="true" />
             <div >
                 <div id="Resultat" class="ui-body ui-body-d ui-corner-all"></div>
        <div data-role="fieldcontain">
          <div data-role="controlgroup" data-type="horizontal" id="unite">
            <input type="radio" name="Unit" id="Unit_0" value="1" />
            <label for="Unit_0">ML</label>
            <input type="radio" name="Unit" id="Unit_1" value="0.001" />
            <label for="Unit_1">L</label>
            <input type="radio" name="Unit" id="Unit_2" value="0.01" />
            <label for="Unit_2">G</label>
          </div>
          </div><!--/fieldcontain-->
       </div><!--/unite-->
                         </div><!--/content-->

        </div><!-- /page -->

問題已解決,我現在已經為.js更改了jquery和jquery mobile的版本,只是一個小問題是,當您更改滑塊的值時,必須在輸入中單擊2x才能看到更新的結果。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM