gpt4 book ai didi

jquery - 选择选项显示 Div 并隐藏一个 Div - JQuery

转载 作者:行者123 更新时间:2023-11-28 18:28:58 26 4
gpt4 key购买 nike

我有一个选择选项

<select class="input_select" name="customer_type" id="central_company">
<option value="standard">Standard</option>
<option value="central">Central Station</option>
</select>

和一个按钮

<div class="standardbutton">
<label class="button_label">
<input type="submit" class="standardbutton" name="button1" value="Submit Form" />
</label>
</div>

点击时使用这个 Jquery

// Show Special Form Elements
$(".cleantestbox").hide();
$('#central_company').change(function() {
var option = $(this).find('option:selected');
$('.cleantestbox').toggle(option.hasClass('central'));
$('.standardbutton').toggle(option.hasClass('standard'));
}).change();

隐藏标准按钮类并显示名为 .cleantestbox 的 div,但它似乎不起作用。它以前工作过的任何想法,但似乎无法找到导致它不工作的原因。

最佳答案

// Show Special Form Elements
$(".cleantestbox").hide();
$('#central_company').change(function() {
if ($(this).val() == 'central') {
$('.cleantestbox').show();
$('.standardbutton').hide();
} else {
$('.cleantestbox').hide();
$('.standardbutton').show();
}
});

关于jquery - 选择选项显示 Div 并隐藏一个 Div - JQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14858074/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com