gpt4 book ai didi

jQuery 不适用于 Bootstrap 3 Modal dom 元素

转载 作者:太空宇宙 更新时间:2023-11-03 23:48:42 25 4
gpt4 key购买 nike

我的目标:

我有一个模式,我想用它来向数据库添加工作职位。我选择开始日期,并选中still-here复选框应该隐藏 ending date 字段并在其位置显示一个 div,上面写着 I currently work here

我的问题:

是不是我的 jQuery 没有在模态上获取 dom 元素...我在复选框上有 console.log() 以查看是否被选中,但它没有工作得那么好。它只提供模式启动时的初始值,而不是每次我选择/取消选择复选框时的值。

查看我的代码示例 here

我的问题:

我错过了什么,为什么它不起作用,我怎样才能实现我的目标?

最佳答案

试试这个

$(document).ready(function() {
$('#myModal').on('shown.bs.modal', function () {
$(".current-position").hide();
console.log($('#still_here').is(':checked'));

});

});

$('#still_here').on('change',function(){
if($('#myModal .modal-body #still_here').prop('checked')){
$("#myModal .modal-body .current-position").show();
console.log($("#myModal .modal-body #to_month"));
$("#myModal .modal-body #to_month").hide();
$("#myModal .modal-body #to_year").hide();
}else{
$("#myModal .modal-body .current-position").hide();
$("#myModal .modal-body #to_month").show();
$("#myModal .modal-body #to_year").show();
}
});

关于jQuery 不适用于 Bootstrap 3 Modal dom 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20835490/

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