gpt4 book ai didi

javascript - 单击更改元素的可见性

转载 作者:太空宇宙 更新时间:2023-11-03 23:31:46 25 4
gpt4 key购买 nike

<table id="selectsupp">
<tr>
<td>
<select id="category">
<option value="display" readonly="true">-Shop By Category-</option>
<option value="all">All</option>
<option value="preworkout">Pre Workout</option>
<option value="protein">Protein</option>
<option value="mass">Mass Gainer</option>
<option value="bcaa">BCAA</option>
</select>
</td>
</tr>
<tr>
<td>
<select id="company">
<option value="display" readonly="true">-Shop By Company-</option>
<option value="all">All</option>
<option value="on">Optimum Nutrition</option>
<option value="mts">MTS</option>
<option value="mutant">Mutant Nutrition</option>
<option value="allmax">All Max</option>
</select>
</td>
<td>
<input type="submit" id="submit" name="search" value="Search" onclick="find()"/>
</td>
</tr>
</table>

<script>
function find(){
var category = document.getElementById('category');
var valueOfCategory = category.options[category.selectedIndex].value;
var company = document.getElementById('company');
var valueOfCompany = company.options[company.selectedIndex].value;

if (valueOfCategory === "all" && valueOfCompany === "all") {
alert "hello";
document.getElementsByTagName("select")[0].style.visibility = "hidden";
document.getElementsByTagName("select")[1].style.visibility = "hidden";
//display all suggested items
}

你好各位编码员:)我在设置标签的可见性时遇到了一些问题。当我提交时,我试图摆脱 2 个选择选项和按钮,但由于某种原因,它设置 .style.visibility = "hidden"不起作用。有什么建议吗?

最佳答案

有两个问题

alert "hello";

应该是

alert("hello");

函数末尾缺少。而且我也没有看到 script 标签的关闭。

关于javascript - 单击更改元素的可见性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25130894/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com