簡體   English   中英

Javascript onclick按鈕在Wordpress中的移動設備上不起作用

[英]Javascript onclick button not working on mobile devices in wordpress

JavaScript OnClick事件按鈕在使用Jquery的移動設備上不起作用。

我研究了很多,嘗試了所有建議,但仍然無法正常工作!!!

此功能在台式機上完美運行!!!

這是一個WordPress站點。

這是我的代碼:

    <div class="smt">
<div class="container-fluid">
    <div class="row">

        <div class="col-lg-12">
            <div class="row">
                <div class="left-column">
                    <input id="noc" class="form" type="text" placeholder="Enter Number of Components"  />
                    <input id="nos" class="form" type="text" placeholder="Enter Number of Suppliers"  />
                </div>
                <div class="btn-container">
                    <button class="btn" id="calculateBtn">Calculate Savings*</button>
                </div>
                 <div class="right-column">
                <h4><b>Hours Saved: <span id="ts" class="result"></span></b></h4>
                <h4><b>Amount Saved: <span id="as" class="result"></span></b></h4>
               </div >
            </div>
        <div class=""></div>
           </div>  
           </div>

    </div>
</div>
<script>

 $(window).load(function() { 
    $('#calculateBtn').on('click touchstart', function() {

    var noc = $("#noc").val();
    var nos = $("#nos").val();
    if (noc == "" && nos == "") {
      //  alert("Please Enter the values in the fields");
    } else {
        var crfq1 = 1;
        var crto1 = 3;
        var ana1 = 2;
        var cpo1 = 2;
        var tt = ((noc * nos) * (crfq1 + crto1 + ana1 + cpo1)) / 60;
        var crfq2 = 1;
        var crto2 = 0;
        var ana2 = 1;
        var cpo2 = 0.5;
        var tt2 = (((noc * nos) + 1) * (ana2 + cpo2)) / 60;
        var tts = tt - tt2;
        var totalAmountSaving = tts * 30;
        $("#ts").text(tts.toFixed(2));
        $("#as").text('$' + totalAmountSaving.toFixed(2));
        var noc = $("#noc").val("").focus();
        var nos = $("#nos").val("");
    }

    });
 });


</script>

謝謝

您可以嘗試使用點擊事件: https : //www.w3schools.com/jquerymobile/event_tap.asp

暫無
暫無

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

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