如何调试“Uncaught ReferenceError:e未定义”?

时间:2017-09-22 22:33:52

标签: jquery wordpress

我想通过选择门票数量并将其乘以100美元来计算总数。

请参阅以下链接了解实际页面。

<script>

     jQuery(document).ready(function() {
       function compute() {
           var a =  jQuery('#nb_billet').val();
           var b = 100
           var total = a * b;
            jQuery('#total').val(total);
         }

        jQuery('#a, #b').change(compute);
              });
</script>

External website

4 个答案:

答案 0 :(得分:0)

您在以下行中遗漏了一个分号:

var b = 100

应该是

var b = 100;

答案 1 :(得分:0)

在你的代码中使用了e.preventDefault(),而在匿名函数中没有传递'e'。

e is  not defined, thats the error

所以请在函数中传递'e'。

修改后的代码:

$(document).click(function(e){
      $('.search-module-opened, .cart-module-opened').hide();
      e.preventDefault();
   });

答案 2 :(得分:0)

使用以下代码:

请勿使用val(),而应使用text()

    jQuery('#total').text(total) 

答案 3 :(得分:0)

尝试使用此代码我刚刚检查过它的工作!

      var a =  jQuery('#a').val();
      var b = 100
      var total = a * b;
      jQuery('#total').text(total);