我有这个复选框:
这是复选框的代码:
<input class="ace ace-switch"
data-toggle="tooltip"
data-placement="top"
value="true"
type="checkbox"
id="checkBoxId"
onclick="switch();" >
点击我想更改 href(url) 并基于该 url 我在页面上隐藏/显示一些其他元素。
这是 onclick
事件的代码:
function switch() {
location.href="../../app/?viewMode=<%= viewMode.equals("presentation")?"full":"presentation" %>"
}
单击 href(url) 时,元素会隐藏或显示,但切换图像始终保持关闭状态。
为什么?
最佳答案
它总是炫耀,因为你正在重新加载页面。您只需根据 viewModel 设置值
<input class="ace ace-switch"
data-toggle="tooltip"
data-placement="top"
value="<%= viewMode.equals("presentation")? "true":"false" %>"
type="checkbox"
id="checkBoxId"
onclick="switch();" >
关于javascript - 复选框输入 - onclick 事件 - 更改 href 和复选框图像/值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49364058/