简体   繁体   English

javascript 代码不适用于我的项目

[英]javascript code doesn't work on my project

I have a wordpress site for my business and I'm using Booked Plugin for Appointments, I want to send some values to mail.我有一个 wordpress 站点用于我的业务,并且我正在使用预约插件进行约会,我想将一些值发送到邮件。 My code works on JsFiddle platform but doesn't work on my project, I check values on Console screen.我的代码适用于 JsFiddle 平台,但不适用于我的项目,我检查控制台屏幕上的值。 JsFiddle shows me the values those what I want, but the project's console screen(I'm using Google Chrome) value returns 0 everytime and doesn't changes. JsFiddle 向我展示了我想要的值,但项目的控制台屏幕(我使用的是 Google Chrome)值每次都返回 0 并且不会改变。 Could you help me?你可以帮帮我吗?

<input data-calendar-id="136" type="checkbox" name="single-checkbox---8012145[]" id="booked-checkbox-single-checkbox---8012145-4" class='test_23' value="CE103">
        var calculate = function() {
      var total = 0;
      // Check if a checkbox is ticked
      if ($('.test_23').is(':checked')) {
        total += 100;
      }

      // A second checkbox
      if ($('.test_24').is(':checked')) {
        total += 150;
      }

      // Display the result to the user
      $('#form-total').text('Total: $' + total);

      console.log(total);
    };

    // Calculate on page load
    calculate();


    // Recalculate when these checkboxes/radio buttons are clicked
    $('.test_23, .test_24').click(calculate);

screenshot from my project's console screen我项目控制台屏幕的屏幕截图

You have to manually include jQuery in your project (jsfiddle may do it for you)您必须在项目中手动包含 jQuery (jsfiddle 可以为您完成)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM