gpt4 book ai didi

javascript - 隐藏 'Clear' 按钮,直到单击 'Apply' 按钮

转载 作者:行者123 更新时间:2023-12-02 17:35:48 25 4
gpt4 key购买 nike

我有一个表单,其中过滤器下方有按钮(应用过滤器和清除过滤器),我试图在单击“应用”按钮时显示“清除”,并在单击“清除”按钮时隐藏“清除”按钮。

下面的代码(如果我的表有的话):

<dl class="filterlist" style="margin-top: 0px">
<dt>
<label for="Environment">Environment</label>
</dt>
<dd>
@Html.DropDownList("EnvironmentDD", (IEnumerable<SelectListItem>)ViewBag.Environment, "- - All Environments - -",
new { @class = "ddstyle", @id = "Environment", @title = "Filter the table below by environment." })
</dd>
<dt>
<label for="Product">Product</label>
</dt>
<dd>
@Html.DropDownList("ProductDD", (IEnumerable<SelectListItem>)ViewBag.Product, "- - All Products - -",
new { @class = "ddstyle", @id = "Product", @title = "Filter the table below by product." })
</dd>
<dt>
<label for="TestType">Test Type</label>
</dt>
<dd>
@Html.DropDownList("TestTypeDD", (IEnumerable<SelectListItem>)ViewBag.TestType, "- - All Test Types - -",
new { @class = "ddstyle", @id="TestType", @title="Filter the table below by test type." })
</dd>
<dt>
<label for="TestScenario">Test Scenario</label>
</dt>
<dd>
@Html.DropDownList("ScenarioDD", (IEnumerable<SelectListItem>)ViewBag.Scenario, "- - All Test Scenarios - -",
new { @class = "ddstyle", @id="TestScenario", @title="Filter the table below by test scenario." })
</dd>
<dt>&nbsp;</dt>
<dd>
<button class="butstyle" id="ApplyFilter" type="submit" title="Click to apply any filters selected above.">
Apply Filter(s) <i class="fa fa-filter"></i>
</button>
<button class="butstyle" id="ClearFilters" title="Click to reset any filters set." style="display:none">
Clear Filter(s) <i class="fa fa-eraser"></i>
</button>
</dd>
</dl>

我该如何做到这一点,或者最好的方法是什么,因为我似乎无法理解它。我正在使用 HTML5 和 MVC5。

默认情况下,该按钮设置为:

style="display:none">

最佳答案

没有 JQuery:

<button onclick="document.getElementById('ClearFilters').style.display='block';" class="butstyle" id="ApplyFilter" type="submit" title="Click to apply any filters selected above.">
Apply Filter(s) <i class="fa fa-filter"></i>
</button>
<button onclick="document.getElementById('ClearFilters').style.display='none';" class="butstyle" id="ClearFilters" title="Click to reset any filters set." style="display:none">
Clear Filter(s) <i class="fa fa-eraser"></i>
</button>

唯一的其他方法是在按下按钮时重新加载页面并检查按下了哪个按钮...

关于javascript - 隐藏 'Clear' 按钮,直到单击 'Apply' 按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22639233/

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