目前,我正在一个网站上工作,我想使用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> </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> </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> </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> </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> </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> </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;">
为了节省空间并防止发布整个页面,我在这里将其停止-上面的内容类似,最后一行是如何列出其他隐藏的内容。
预期结果是它在站点设置显示中的表之间切换为当前表的“ none”,而将下一个设置为“ block”。