Ver Mensaje Individual
  #3 (permalink)  
Antiguo 07/05/2010, 07:28
tazzwt
 
Fecha de Ingreso: marzo-2010
Mensajes: 432
Antigüedad: 14 años, 1 mes
Puntos: 11
Respuesta: checkbox color con celda

muchas gracias funciona super bien. cuando le hago click.

Pero que sucede en el caso que si ya el checkbox se encuentra marcado.

Código HTML:
Ver original
  1. <input type="checkbox" name="checkbox" id="check1" value="checkbox" checked>

cuando cargue la pagina como lo va a reconocer ?


Código HTML:
Ver original
  1. <script src="jquery.js" type="text/javascript"></script>
  2.  
  3. <script languaje="javascript">
  4.  
  5.  $(document).ready(function(){
  6.  
  7.     $('#check1').load(function(){
  8.       if($(this).attr('checked') == true) {
  9.         $(this).parent().attr('style','background:#ff0000;')
  10.       } else {
  11.         $(this).parent().removeAttr('style')
  12.         // o $(this).parent().attr('style','background:#ff0000;') y elejis el color si no esta seleccionado
  13.       }
  14.     })
  15.  
  16. });
  17.  
  18.  
  19. <div align="left">
  20.   <table width="200" border="1" cellspacing="1" cellpadding="1">
  21.     <tr>
  22.       <th scope="col"><div align="center">
  23.         <input type="checkbox" name="checkbox" id="check1" value="checkbox" checked>
  24.       </div></th>
  25.       <th scope="col"><div align="center">
  26.         <input type="checkbox" name="checkbox2" value="checkbox">
  27.       </div></th>
  28.       <th scope="col"><div align="center">
  29.         <input type="checkbox" name="checkbox3" value="checkbox">
  30.       </div></th>
  31.     </tr>
  32.     <tr>
  33.       <td><div align="center">
  34.         <input type="checkbox" name="checkbox6" value="checkbox">
  35.       </div></td>
  36.       <td><div align="center">
  37.         <input type="checkbox" name="checkbox5" value="checkbox">
  38.       </div></td>
  39.       <td><div align="center">
  40.         <input type="checkbox" name="checkbox4" value="checkbox">
  41.       </div></td>
  42.     </tr>
  43.     <tr>
  44.       <td><div align="center">
  45.         <input type="checkbox" name="checkbox7" value="checkbox">
  46.       </div></td>
  47.       <td><div align="center">
  48.         <input type="checkbox" name="checkbox8" value="checkbox">
  49.       </div></td>
  50.       <td><div align="center">
  51.         <input type="checkbox" name="checkbox9" value="checkbox">
  52.       </div></td>
  53.     </tr>
  54.     <tr>
  55.       <td><div align="center">
  56.         <input type="checkbox" name="checkbox14" value="checkbox">
  57.       </div></td>
  58.       <td><div align="center">
  59.         <input type="checkbox" name="checkbox13" value="checkbox">
  60.       </div></td>
  61.       <td><div align="center">
  62.         <input type="checkbox" name="checkbox10" value="checkbox">
  63.       </div></td>
  64.     </tr>
  65.     <tr>
  66.       <td><div align="center">
  67.         <input type="checkbox" name="checkbox15" value="checkbox">
  68.       </div></td>
  69.       <td><div align="center">
  70.         <input type="checkbox" name="checkbox12" value="checkbox">
  71.       </div></td>
  72.       <td><div align="center">
  73.         <input type="checkbox" name="checkbox11" value="checkbox">
  74.       </div></td>
  75.     </tr>
  76.   </table>
  77. </div>