gpt4 book ai didi

Jquery - 根据复选框值隐藏/显示

转载 作者:行者123 更新时间:2023-12-01 02:54:46 25 4
gpt4 key购买 nike

您好,我有以下表格:

               {{ Form::open(array('url' => 'profile', 'class' => 'form-horizontal')) }}
<div class="checkbox-custom fill checkbox-success mb5">
<fieldset class="arma2-mysql-question">
{{ Form::checkbox('arma2-mysql', '', $user->arma2_mysql, ['id' => 'arma2-mysql', 'onChange' => 'valueChanged()']) }}
{{ Form::label('arma2-mysql', 'Arma2 MySQL') }}
</fieldset>
</div>
<fieldset class="arma2-mysql-answer">
{{ Form::label('databaseip', 'Database IP') }}
{{ Form::text('databaseip', $user->arma2_mysql_ip, array('class' => 'form-control')) }}
{{ Form::label('database', 'Database') }}
{{ Form::text('database', $user->arma2_mysql_database, array('class' => 'form-control')) }}
{{ Form::label('databaseusername', 'Database Username') }}
{{ Form::text('databaseusername', $user->arma2_mysql_username, array('class' => 'form-control')) }}
{{ Form::label('databasepassword', 'Database Password') }}
{{ Form::password('databasepassword', array('class' => 'form-control')) }}
</fieldset>
{{ Form::close() }}

和以下脚本:

function valueChanged() {
if ($('.arma2-mysql').is(':checked')) {
$(".arma2-mysql-answer").hide();
} else {
$(".arma2-mysql-answer").show();
}
}

取消选中时效果很好,但是再次检查时不会显示表单?

有什么想法吗?

最佳答案

尝试使用切换:

$('.arma2-mysql').change(function(){
$('.arma2-mysql-answer').toggle(!this.checked);
});

关于Jquery - 根据复选框值隐藏/显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27971034/

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