隐藏'清除'按钮,直到'按钮点击
Hide a 'Clear' button until the 'Apply' button clicked
我有一个表单,在我的过滤器下面有按钮(应用过滤器&清除过滤器)当点击"应用"按钮时,我试图显示"清除",当点击"清除"按钮时隐藏"清除"按钮。
下面的代码表示我的表:
<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> </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/jquery使用jquery。这是你要找的吗?
$("#ApplyFilter").click(function(){
$("#ClearFilters").toggle();
$(this).toggle();
});
$("#ClearFilters").click(function(){
$("#ApplyFilter").toggle();
$(this).toggle();
});
看看我在你的html里做了什么
已经决定,虽然隐藏'Clear'按钮将是一个'很好的',它应该显示在任何时候,并可能在未来的修复隐藏它一旦应用程序启动和运行。
感谢所有的评论/帮助。
相关文章:
- 等待,直到使用Java在selenium网络驱动程序中手动单击登录按钮
- 隐藏结账按钮,直到选择发货选项
- 禁用按钮,直到完成所有必填字段
- 在单击按钮时激活按钮的悬停状态,直到单击另一个按钮(Javascript/JQuery)
- 单击一个按钮,直到它在CasperJS中消失
- 如何在第一次单击后禁用搜索按钮,直到结果来自服务器
- 禁用浏览器按钮,直到页面加载完成
- 在提交时更改按钮颜色,直到输入新文本
- 如何禁用提交按钮,直到特定字段中的验证通过
- 如何禁用提交按钮,直到选择下拉值
- 如何让窗口消息保持不变,直到用户单击按钮才离开页面
- 禁用交易按钮,直到 asp.net 页面中的交易结束
- 禁用按钮,直到表单域为空,但按钮在表单之外
- 带有保存和提交按钮的 2 列表单,并尝试禁用提交按钮,直到表单完成
- 是否可以阻止 Oracle Apex 提交页面,直到用户单击该页面上的刷新按钮
- 保持提交按钮处于禁用状态,直到填充动态创建的必填字段
- 禁用按钮,直到单击一个单选按钮
- 如何隐藏单选按钮直到出现问题
- Facebook分享按钮直到刷新后才显示
- 禁用按钮直到值被选中---选择---不会出现