【发布时间】:2017-12-02 11:06:00
【问题描述】:
我找到了一种使用 CSS 切换 span 或 input 元素可见性的方法,基于是否选中了单选框(受此 question 启发)。
但是,一旦应用 jQueryUI 微调器格式,我就会失去这种切换效果。
这个jsFiddle 展示了 CSS 如何在span 元素上正常工作,但不适用于input。事实上,只要我应用微调器,整个 input 就会消失。
任何线索为什么会发生这种情况,以及如何使用 CSS 切换其可见性?
这是我在小提琴中使用的 CSS:
/* Control visibility of SPAN and INPUT (with jqueryui spinner class)
cf. https://stackoverflow.com/questions/21269376/radio-button-show-hide-content
*/
/*The span works fine*/
span#some-text {
display:none;
}
input#on-input:checked ~ span#some-text{
display:inline;
}
input#systematic-input:checked ~ span#some-text{
display:none;
}
/*The input is only visible when the spinner format isn't applied (i.e. commenting all CSS below this point). Even so, the hide/show effect doesn't work. Why?*/
/*
input#spinner-on {
display:none;
}
input#on-input:checked ~ input#spinner-on{
display:inline;
}
input#off-input:checked ~ input#spinner-on{
display:none;
}
*/
【问题讨论】:
-
但这行得通。 . . jsfiddle.net/47zw914j
-
@hex 它可以工作,但只是因为不再应用 jQueryUI“微调器”格式。正如下面的 AlkaRocks 所建议的那样,我正在寻找一个激活微调器的工作解决方案。
标签: jquery css jquery-ui spinner