当页面有超过1组数据报警器时,我试图使此代码工作。
如果选择“我目前在这里工作”选项,它会影响两个组,而我希望只影响当前组。
我的代码
$('.current-work-status').change(function () {
$('.form-control-2').prop('disabled', $(this).is(':checked'));
});发布于 2015-06-03 09:56:08
试一试
$('.current-work-status').change(function () {
$(this).closest('div').prev().find('.form-control-2').prop('disabled', this.checked);
});更新fidle
发布于 2015-06-03 09:53:36
试一试
演示
使用jQuery .parents()选择器查找组的父项,并使用.find()、get、.form-control-2和update属性。
$('.current-work-status').change(function () {
$(this).parents('div.row').find('.form-control-2').prop('disabled', $(this).is(':checked'));
});https://stackoverflow.com/questions/30616612
复制相似问题