1
What I want to do with the checkbox
, is the same as the radio
does using the Javascript.
'Cause I just don’t use the radio
?
It is because if the radio
appear marked, there is no way I leave it unchecked.
I know the logic in Javascript is right, because you can see by console.log
, but when I click on another input
he does not clear what is marked.
var obj2 = "";
var box = document.querySelectorAll(".t");
box[0].addEventListener("click",selecionarGru);
box[1].addEventListener("click",selecionarGru);
function selecionarGru(){
if(obj2 == "" || obj2 == this){
if(obj2 == this){
obj2.removeAttribute('checked');
obj2 = "";
return;
}
obj2 = this;
obj2.setAttribute("checked","");
}else{
obj2.removeAttribute('checked');
obj2 = this;
obj2.setAttribute("checked","");
}
}
#tudo1{
background: green;
width: 200px;
height: 200px;
}
.t{
width: 20px;
height: 20px;
margin: 30px 0 0 80px;
background: red;
}
<div id="tudo1">
<input type="checkbox" class="t">
<input type="checkbox" class="t">
</div>
could not create another radio with no option?
– Costamilam
Yes, it would have been easier to think about it before your comment and I’m already doing it! But it’s giving shit the same way. my idea to use js to check if I gave a second click on the same radio so it would mark an invisible radio. however I put the attribute checked on the invisible radio and it does not uncheck the visible https://codepen.io/pedroviskks/pen/YYNBog
– AKU
adds an id on each checkbox that Voce wants and cycle using the checkbox and not the name of the field pq Voce can not pull this the other elements at the same time only one of them
– Gustavo Castro