我目前正在一个网站上工作,我想使用Javascript来改变一个定价表的信息,通过每月循环到季度,到每年回到每月。我已经修复了火狐(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;">
为了节省空间和防止张贴整个页面,我在这里停止了它-它在上面继续,最后一行是如何设置其他隐藏的开始。
预期的结果是,它在站点上的表之间交换,将当前表上的显示设置为“无”,并将下一个表设为“块”。
发布于 2019-07-05 13:05:59
已在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> </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;">
https://stackoverflow.com/questions/56896760
复制相似问题