javascript - Javascript 的未知错误,开发人员菜单中没有任何内容 (F12)

标签 javascript html css

我目前正在一个网站上工作,我想使用 Javascript 更改定价表的信息,以循环从每月到每季度再到每年再到每月。我已解决在 Firefox (F12) 的开发者菜单中出现的问题。目前,当我点击按钮时没有任何反应,包括我没有收到任何错误消息。

我已尝试更改浏览器和设备,但我仍然没有收到来自 javascript 的响应。

这是网站的区域:

function myFunction() {
  var m = document.getElementById("whPricingMonthly");
  var q = document.getElementById("whPricingQuart");
  var a = document.getElementById("whPricingAnnual");

  if (m.style.display === "block") {
    m.style.display === "none";
    q.style.display === "block";
  } else if (q.style.display === "block") {
    q.style.display === "none";
    a.style.display === "block";
  } else if (a.style.display === "block") {
    m.style.display === "block";
    a.style.display === "none";
  } else {
    m.style.display === "block";
    a.style.display === "none";
  }
}
<div class="d-flex d-sm-flex d-lg-flex justify-content-center justify-content-sm-center justify-content-lg-center">

  <button onclick="myFunction()" class="btn btn-warning d-sm-flex d-lg-flex justify-content-sm-center outline" type="button">Change payment time <br>(Monthly, Quaterly, Annually)</button>

</div><br>


<div class="col comparison" id="whPricingMonthly" style="display:block;">
  <table>
    <thead>
      <tr class="price-header">
        <th class="tl tl2" valign="bottom"><span class="price-options-desc">Monthly Pricing Options</span></th>
        <th class="qbse qbse-first"> Small <span class="table-price">$2<small>.80</small><span style="font-size:16px;">/pm</span></span>
        </th>
        <th class="qbse qbse-second"> Business <span class="table-price">$4<span style="font-size:16px;">/pm</span></span>
        </th>
        <th class="qbse qbse-third"> Platinum <span class="table-price">$8<span style="font-size:16px;">/pm</span></span>
        </th>
        <th class="qbse qbse-last"> Ultimate <span class="table-price">$11<span style="font-size:16px;">/pm</span></span>
        </th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td></td>
        <td colspan="4">Disk Space</td>
      </tr>
      <tr class="compare-row">
        <td>Disk Space</td>
        <td>10GB</td>
        <td>20GB</td>
        <td>50GB</td>
        <td><strong>Unmetered</strong></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="4">Bandwidth</td>
      </tr>
      <tr>
        <td>Bandwidth</td>
        <td><strong>Unmetered</strong></td>
        <td><strong>Unmetered</strong></td>
        <td><strong>Unmetered</strong></td>
        <td><strong>Unmetered</strong></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="4">Email Accounts</td>
      </tr>
      <tr class="compare-row">
        <td>Email Accounts</td>
        <td>3</td>
        <td>25</td>
        <td>50</td>
        <td><strong>Unlimited</strong></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="4">Mailing Lists</td>
      </tr>
      <tr>
        <td>Mailing Lists</td>
        <td><span class="tickblue">✔</span></td>
        <td><span class="tickgreen">✔</span></td>
        <td><span class="tickgreen">✔</span></td>
        <td><span class="tickgreen">✔</span></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="4">MySQL Databases</td>
      </tr>
      <tr class="compare-row">
        <td>MySQL Databases</td>
        <td>2</td>
        <td>4</td>
        <td>10</td>
        <td><strong>Unlimited</strong></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="4">Subdomains</td>
      </tr>
      <tr>
        <td>Subdomains</td>
        <td>5</td>
        <td>8</td>
        <td>12</td>
        <td><strong>Unlimited</strong></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="4">Parked Domains</td>
      </tr>
      <tr class="compare-row">
        <td>Parked Domains</td>
        <td>2</td>
        <td>3</td>
        <td>6</td>
        <td><strong>Unlimited</strong></td>
      </tr>
    </tbody>
    <tfoot>
      <tr>
        <td class="options"></td>
        <td class="package-btn pack-1"><a href="#" class="n-button n-button-grey show-free-download">Purchase</a></td>
        <td class="package-btn pack-2"><a href="#" class="n-button n-button-blue">Purchase</a></td>
        <td class="package-btn pack-3"><a href="#" class="n-button n-button-purple">Purchase</a></td>
        <td class="package-btn pack-4"><a href="#" class="n-button n-button-green">Purchase</a></td>
      </tr>
    </tfoot>
  </table>
</div>



<!--             --------------------------------------------------------------            -->



<div class="col comparison" id="whPricingQuart" style="display:none;">

为了节省空间并避免张贴整个页面,我在这里停止了它 - 它与上面类似,最后一行是隐藏的其他内容的设置方式。

预期的结果是它在网站上的表之间交换,在当前表上将显示设置为“无”,并将下一个表设置为“阻止”。

最佳答案

=== 更改为 = inside if 条件。 m.style.display = "none"; ===用于比较值,=用于赋值。 需要帮助请叫我。谢谢

function myFunction() {
  var m = document.getElementById("whPricingMonthly");
  var q = document.getElementById("whPricingQuart");
  var a = document.getElementById("whPricingAnnual");
  
  if (m.style.display === "block") {
    m.style.display = "none";
    q.style.display = "block";
  } else if (q.style.display === "block") {
    q.style.display = "none";
    a.style.display = "block";
  } else if (a.style.display === "block") {
    m.style.display = "block";
    a.style.display = "none";
  } else {
    m.style.display = "block";
    a.style.display = "none";
  }
}
<div class="d-flex d-sm-flex d-lg-flex justify-content-center justify-content-sm-center justify-content-lg-center">

  <button onclick="myFunction()" class="btn btn-warning d-sm-flex d-lg-flex justify-content-sm-center outline" type="button">Change payment time <br>(Monthly, Quaterly, Annually)</button>

</div><br>


<div class="col comparison" id="whPricingMonthly" style="display:block;">
  <table>
    <thead>
      <tr class="price-header">
        <th class="tl tl2" valign="bottom"><span class="price-options-desc">Monthly Pricing Options</span></th>
        <th class="qbse qbse-first"> Small <span class="table-price">$2<small>.80</small><span style="font-size:16px;">/pm</span></span>
        </th>
        <th class="qbse qbse-second"> Business <span class="table-price">$4<span style="font-size:16px;">/pm</span></span>
        </th>
        <th class="qbse qbse-third"> Platinum <span class="table-price">$8<span style="font-size:16px;">/pm</span></span>
        </th>
        <th class="qbse qbse-last"> Ultimate <span class="table-price">$11<span style="font-size:16px;">/pm</span></span>
        </th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td></td>
        <td colspan="4">Disk Space</td>
      </tr>
      <tr class="compare-row">
        <td>Disk Space</td>
        <td>10GB</td>
        <td>20GB</td>
        <td>50GB</td>
        <td><strong>Unmetered</strong></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="4">Bandwidth</td>
      </tr>
      <tr>
        <td>Bandwidth</td>
        <td><strong>Unmetered</strong></td>
        <td><strong>Unmetered</strong></td>
        <td><strong>Unmetered</strong></td>
        <td><strong>Unmetered</strong></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="4">Email Accounts</td>
      </tr>
      <tr class="compare-row">
        <td>Email Accounts</td>
        <td>3</td>
        <td>25</td>
        <td>50</td>
        <td><strong>Unlimited</strong></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="4">Mailing Lists</td>
      </tr>
      <tr>
        <td>Mailing Lists</td>
        <td><span class="tickblue">✔</span></td>
        <td><span class="tickgreen">✔</span></td>
        <td><span class="tickgreen">✔</span></td>
        <td><span class="tickgreen">✔</span></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="4">MySQL Databases</td>
      </tr>
      <tr class="compare-row">
        <td>MySQL Databases</td>
        <td>2</td>
        <td>4</td>
        <td>10</td>
        <td><strong>Unlimited</strong></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="4">Subdomains</td>
      </tr>
      <tr>
        <td>Subdomains</td>
        <td>5</td>
        <td>8</td>
        <td>12</td>
        <td><strong>Unlimited</strong></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="4">Parked Domains</td>
      </tr>
      <tr class="compare-row">
        <td>Parked Domains</td>
        <td>2</td>
        <td>3</td>
        <td>6</td>
        <td><strong>Unlimited</strong></td>
      </tr>
    </tbody>
    <tfoot>
      <tr>
        <td class="options"></td>
        <td class="package-btn pack-1"><a href="#" class="n-button n-button-grey show-free-download">Purchase</a></td>
        <td class="package-btn pack-2"><a href="#" class="n-button n-button-blue">Purchase</a></td>
        <td class="package-btn pack-3"><a href="#" class="n-button n-button-purple">Purchase</a></td>
        <td class="package-btn pack-4"><a href="#" class="n-button n-button-green">Purchase</a></td>
      </tr>
    </tfoot>
  </table>
</div>



<!--             --------------------------------------------------------------            -->



<div class="col comparison" id="whPricingQuart" style="display:none;">

关于javascript - Javascript 的未知错误,开发人员菜单中没有任何内容 (F12),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56896760/

相关文章:

javascript - 带有 html css bootstrap 的小元素(灯箱)

javascript - AngularJs 不同路线的多种布局

javascript - 如何在四个象限中划分部分+在独立于部分点击的可折叠列表框中进行点击

javascript - 如何从 ThreeJS 的场景中导出图像

jquery - 滚动顶部并在加载时添加效果

css - 为什么 google 字体 oswald 在 Firefox 和 Chrome 中不显示,但在其他网络浏览器中显示?

javascript - 调整页面大小时的图像拉伸(stretch) - 通过 jquery 更改了 css - 需要刷新吗?

javascript - 使用 Bootstrap JQuery 和 Mandril 表单中的复选框

css - float Div 在移动后调整大小

html - 包装视频元素会导致奇怪的高度