Ver Mensaje Individual
  #8 (permalink)  
Antiguo 04/04/2013, 18:21
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 10 meses
Puntos: 1567
Respuesta: cambiar color

Lo más práctico en js puro, requeriría alterar un poco la estructura pero sería lo más simple, se puede hacer igual sin agregar ese div extra, pero ya es más complicado

Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <title>titulo</title>
  5. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  6. <script type="text/javascript">
  7. //<![CDATA[
  8. function cambiaColor(e){
  9. if (document.all && document.querySelector && !document.addEventListener) { // <-- compatibilidad IE8
  10. e.previousSibling.style.color = 'red';
  11. }else{
  12. e.previousSibling.previousSibling.style.color = 'red';
  13. }
  14. }
  15. //]]>
  16. </head>
  17. <h1>hola mundo</h1>
  18. <div onmouseover="cambiaColor(this);">
  19. <div id="uno">a</div>
  20. <div id="dos">b</div>
  21. <div id="tres">c</div>
  22. </div>
  23. <h1 id="titledos">hola mundo dos</h1>
  24. <div onmouseover="cambiaColor(this);">
  25. <div id="unoa">d</div>
  26. <div id="dosb">e</div>
  27. <div id="tresc">f</div>
  28. </div>
  29. </body>
  30. </html>

Saludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.