我正在重置基于另一个组合框的组合框。我有2个组合框,当我选择01
然后second combo
被激活了,当我从2nd combo
选择一个选项,然后一个text box
出现,而当我选择“请选择”从first combo
然后2nd combo
是自动复位(禁止),但为什么文本框不会消失?组合框复位时隐藏文本框
当除了第一个选项一个选项是从第二个组合中选择,我填充像一个文本框:
$(function() {
//This hides all initial textboxes
$('label').hide();
$('#secondcombo').change(function() {
//This saves some time by caching the jquery value
var val = $(this).val();
//this hides any boxes that the previous selection might have left open
$('label').hide();
//This just opens the ones we want based off the selection
switch (val) {
case 'option1':
case 'option4':
case 'other':
$('#label1').show();
break;
}
});
//I'm not really sure why these are here
$("input").focus(function() {
$(this).next("span").fadeIn(500);
}).blur(function() {
$(this).next("span").fadeOut(1000);
});
});
HTML
<select id='firstcombo'>
<option value="">please select</option>
<option value="01">01</option>
<option value="02">02</option>
</select>
<select id='secondcombo' disabled="true">
<option value="_">- select -</option>
<option value="option1">data</option>
<option value="option2">data</option>
</select>
<label id="label1" for="option1">
<input type="text" id="option1" />
</label>
这是最简单的方法...如果你想要做的事更多的功能,这个然后绑定这个像第二个组合 – 2012-03-03 07:13:05
感谢Shivam,但如果我有一个以上的标签,该标签是label1,label2,label3 ...那么我该如何编辑这个'''jQuery('label#label1')。hide();'? – Tom 2012-03-03 07:18:04
@tom:你只能使用'$('label')。hide )',如果你不知道你的标签都抱着IDS。 – codef0rmer 2012-03-03 07:22:08