如果条件为假,即使语句正在执行

时间:2019-06-27 00:43:13

标签: jquery if-statement

仅在条件为假的情况下执行语句时才执行代码。

我尝试了调试,我给出的条件肯定是错误的回复,但不确定为什么

 if (
    $("#ship-to-different-address-checkbox").length != 0 &&
    $(".shipping_address").length == 0
  ) {
    postcode = $("#shipping_postcode").val();
  } else {
    postcode = $("#billing_postcode").val();
  }

我也尝试过

     if (
        $("#ship-to-different-address-checkbox").length != 0 &&
        $(".shipping_address").is(":visible")
      ) {
        postcode = $("#shipping_postcode").val();
      } else {
        postcode = $("#billing_postcode").val();
      }

无论if语句要执行什么操作。有人可以帮我吗?

0 个答案:

没有答案