mardi 5 octobre 2021

How modify styles of an element by check an input radio

`let inputs = document.querySelectorAll('input[type="radio"]');

      inputs.forEach( el => {
        el.addEventListener("change", (e)=>{
          let targ = e.target;
          let toChange = document.querySelector('.select-answer');
          console.log(el)
          if(targ == el && el.getAttribute('aria-selected') == 'false' && el.getAttribute('data-id')){
            console.log(targ);
            toChange.classList.toggle('false');
          }
        },false);`

I selected second input but the styles was aplied just for first element




Aucun commentaire:

Enregistrer un commentaire