Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如果复选框被禁用,如何将图像替换为复选框?_Javascript_Html_Jquery - Fatal编程技术网

Javascript 如果复选框被禁用,如何将图像替换为复选框?

Javascript 如果复选框被禁用,如何将图像替换为复选框?,javascript,html,jquery,Javascript,Html,Jquery,代码运行良好,但我想用禁用的图像或图标替换这些复选框。那么,我该怎么做呢 $(文档).ready(函数(){ $('.list dis input[type=“checkbox”]')。每个(函数(){ if($(this).closest('tr').index()!==0){ $(this.prop('disabled',true); } }).on('change',function()){ $(this.prop('disabled',true); $(this).closest('t

代码运行良好,但我想用禁用的图像或图标替换这些复选框。那么,我该怎么做呢

$(文档).ready(函数(){
$('.list dis input[type=“checkbox”]')。每个(函数(){
if($(this).closest('tr').index()!==0){
$(this.prop('disabled',true);
}
}).on('change',function()){
$(this.prop('disabled',true);
$(this).closest('tr').next('tr').find('input[type=“checkbox”]).prop('disabled',false);
});
});

像这样吗

$(文档).ready(函数(){
$('.list dis input[type=“checkbox”]')。每个(函数(){
if($(this).closest('tr').index()!==0){
$(this.prop('disabled',true).hide()
$(this.next().show())
}
}).on('change',function()){
$(this.prop('disabled',true)
$(this).closest('tr').next('tr').find('input[type=“checkbox”]).prop('disabled',false).show()
.next().hide()
});
});
.list disimg{display:none}

像这样吗

$(文档).ready(函数(){
$('.list dis input[type=“checkbox”]')。每个(函数(){
if($(this).closest('tr').index()!==0){
$(this.prop('disabled',true).hide()
$(this.next().show())
}
}).on('change',function()){
$(this.prop('disabled',true)
$(this).closest('tr').next('tr').find('input[type=“checkbox”]).prop('disabled',false).show()
.next().hide()
});
});
.list disimg{display:none}

查看此代码片段:


试验
$(文档).ready(函数(){
$('.list dis input[type=“checkbox”]')。每个(函数(){
if($(this).closest('tr').index()!==0){
$(this.prop('disabled',true);
}
}).on('change',function()){
$(this.prop('disabled',true);
$(this).closest('tr').next('tr').find('input[type=“checkbox”]).prop('disabled',false);
$(this.prop('outerHTML','');
});
});

查看此代码片段:


试验
$(文档).ready(函数(){
$('.list dis input[type=“checkbox”]')。每个(函数(){
if($(this).closest('tr').index()!==0){
$(this.prop('disabled',true);
}
}).on('change',function()){
$(this.prop('disabled',true);
$(this).closest('tr').next('tr').find('input[type=“checkbox”]).prop('disabled',false);
$(this.prop('outerHTML','');
});
});


我想你可以用一个div来包装它,当一个条件满足时,你可以将该div的innerHTML设置为一个图标而不是一个复选框。你可以用css pseudo:disabled:checked来创建它,而不需要任何js。我想你可以用一个div来包装它,当一个条件满足时,您将该div的innerHTML设置为图标而不是复选框。您可以使用css创建它,而无需任何js。pseudo:disabled:checked我想在它之前放置图标或图像以代替禁用的复选框。当我选中复选框时,请按照您的代码选中复选框,然后选中复选框隐藏,但我想显示图像以代替禁用的复选框在检查之前。请我想把图标或图像放在禁用复选框的位置,然后再根据您的代码选中复选框,当我选中复选框时,然后选中复选框是隐藏的,但我想显示图像来代替在选中之前禁用的复选框。请在checkis before=Upper或before=background之前显示图像以代替那些在checkis before=Upper或before=background之前被禁用的复选框?抱歉,我无法获取您的信息。是否要更改已禁用复选框的背景?或者当用户在图像上方标记复选框时,您想将图像放在那里并用复选框替换它?@mplungjan再次感谢您的帮助:)我记得您。这是一个错误按下的Ctrl+CI想要显示图像来代替那些在checkis before=upper或before=background之前被禁用的复选框吗?很抱歉,我找不到你要更改被禁用复选框的背景吗?或者当用户在图像上方标记复选框时,您想将图像放在那里并用复选框替换它?@mplungjan再次感谢您的帮助:)我记得您。这是一个错误地按Ctrl+C组合键