我使用jquery为复选框准备了这个隐藏的功能。 https://jsfiddle.net/o2c8z5xw/单击“隐藏”时,复选框将消失。如何在打开页面时默认执行此操作,而不是单击?
HTML code:
<label><input type="checkbox" id="Hidden" name="Hidden" class="hidden"/>Hidden</label>
<form id="form1" name="form1" method="post" action="">
<label><input type="checkbox" name="SelectAll" class="all" />All</label>
<label><input type="checkbox" name="5" class="selector" />5</label>
<label><input type="checkbox" name="7" class="selector" />7</label>
<label><input type="checkbox" name="9" class="selector" />9</label>
</form>
Jquery代码:
$( "#Hidden").on( "click", function() {
$(".selector").toggle();
});
答案 0 :(得分:1)
文档准备好后,您可以from multiprocessing import Pipe, Process
class BaseDevice:
# Various methods
pass
class BaseInstr(BaseDevice, Process):
def __init__(self, pipe):
Process.__init__(self)
self.pipe = pipe
def run(self):
# Do stuff and wait for terminate message on pipe
# Various other higher level methods
class BaseCompountInstrument(BaseInstr):
def __init__(self, pipe):
# Create multiple instruments, usually done with config file but simplified here
BaseInstr.__init__(self, pipe)
instrlist = list()
for _ in range(5):
masterpipe, slavepipe = Pipe()
instrlist.append([BaseInstr(slavepipe), masterpipe])
def run(self):
pass
# Listen for message from pipe, send messages to sub-instruments
def shutdown(self):
# When shutdown message received, send to all sub-instruments
pass
class test(unittest.TestCase):
def setUp(self):
# Load up a configuration file from the sample configs so that they're updated
self.parentConn, self.childConn = Pipe()
self.instr = BaseCompountInstrument( self.childConn)
self.instr.start()
def tearDown(self):
self.parentConn.send("shutdown") # Propagates to all sub-instruments
def test1(self):
pass
def test2(self):
pass
。
toggle
答案 1 :(得分:0)
答案 2 :(得分:0)
这是基于CSS的解决方案,没有JS更改。
使用.selector
隐藏display: none
元素,同时注意将checked
属性添加到“隐藏”复选框,以便界面仍然有意义(否则切换行为将是隐藏复选框的对面)。
$("#Hidden").on("click", function() {
$(".selector").toggle();
});
.selector {
display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label><input type="checkbox" id="Hidden" name="Hidden" class="hidden" checked />Hidden</label>
<form id="form1" name="form1" method="post" action="">
<label><input type="checkbox" name="SelectAll" class="all" />All</label>
<label><input type="checkbox" name="5" class="selector" />5</label>
<label><input type="checkbox" name="7" class="selector" />7</label>
<label><input type="checkbox" name="9" class="selector" />9</label>
</form>
答案 3 :(得分:0)
我同意Maarten上面的解决方案,并且使用了一个挑剔的方法,将“选择器隐藏”类添加到复选框并将其切换为更有意义。
CSS:
.selector-hidden {
display: none;
}
JQuery的:
$( "#Hidden").on( "click", function() {
$(".selector-hidden").toggle();
});
这样选择器可以使用'selector'类进行样式设置,但可以通过切换'selector-hidden'类来隐藏。