Ver Mensaje Individual
  #2 (permalink)  
Antiguo 12/09/2012, 13:54
Avatar de Dradi7
Dradi7
 
Fecha de Ingreso: junio-2008
Ubicación: Peru - Lima
Mensajes: 1.518
Antigüedad: 15 años, 10 meses
Puntos: 220
Respuesta: Cambiar color borde radio buton

bueno sera cambiar el fondo del radiobutton porque el mismo radiobutton no se pueda

Ejemplo:

Código HTML:
Ver original
  1. <div><input type="radio" value="1" name="rb" />OK</div>
  2. <div><input type="radio" value="2" name="rb" />OK</div>

Código Javascript:
Ver original
  1. window.onload = function(){
  2.     var r = document.getElementsByName("rb");
  3.     for(var x=0;r[x];x++){
  4.         if(window.attachEvent)
  5.             r[x].attachEvent("onclick",Cambia);
  6.         else
  7.             r[x].addEventListener("click",Cambia);
  8.     }
  9. };
  10.  
  11. function Cambia(){
  12.     var ele = this;
  13.     var r = document.getElementsByName("rb");
  14.     for(var x=0;r[x];x++){
  15.         if(r[x].value === ele.value){
  16.             console.log('dentro');
  17.             r[x].parentNode.style.backgroundColor="red";
  18.         }else{
  19.             r[x].parentNode.style.backgroundColor=""
  20.         }
  21.     }
  22. }&#8203;
__________________
La clave de todo triunfador es eliminar todas sus excusas y sus limitaciones