我有以下设置,其中添加了自定义复选标记来设置单选按钮的样式。但它也会将该复选标记添加到文本类型输入中。
var changed =function(){
Array.from(document.querySelectorAll("table")).forEach((element,index) =>
{
Array.from(element.querySelectorAll("input")).forEach((myinp,index) =>
{
if(myinp.checked==true){
myinp.parentNode.parentNode.classList.add("active");
}else{
myinp.parentNode.parentNode.classList.remove("active");
}
});
});
}//changed function ends
Array.from(document.querySelectorAll("table")).forEach((element,index) =>
{
Array.from(element.querySelectorAll("input")).forEach((myinp,index) =>
{
var checkmark = document.createElement("span");
checkmark.classList.add("checkmark");
myinp.parentNode.appendChild(checkmark);
myinp.addEventListener("change", changed);
});
});Run Code Online (Sandbox Code Playgroud)
table tbody tr td:first-child{
position:relative;
}
.confirmit-table tbody tr input[type='radio'][type='checkbox']{
visibility:hidden
}
/*Create a custom checkbox */
.checkmark,.dotmark {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 25px;
background-color: #eee;
}
input[type='text']{
width:20px;
}
/* On mouse-over, add a grey background color */ …Run Code Online (Sandbox Code Playgroud)