Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/04/2009, 15:11
Avatar de pato12
pato12
 
Fecha de Ingreso: septiembre-2007
Ubicación: Salta
Mensajes: 1.620
Antigüedad: 17 años, 4 meses
Puntos: 101
No anda setAttribute

Hola,
Estoy creando una funcion que me cambie el css:
Código html:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  4. <title>Documento sin t&iacute;tulo</title>
  5. <script type="text/javascript">
  6. <!--
  7. function $(id){
  8.     return document.getElementById(id);
  9. }
  10. function $css(id,ob){
  11.     for (at in ob) {
  12.         if(at=="opacity"){
  13.             $(id).style.opacity=(ob[at]);
  14.             $(id).style.MozOpacity=(ob[at]);
  15.             $(id).style.KhtmlOpacity=(ob[at]);
  16.             $(id).style.filter="alpha(opacity="+ob[at]+")";
  17.         }else{
  18.             $(id).setAttribute(at,""+ob[at]);
  19.         }
  20.     }
  21. }
  22. -->
  23. </head>
  24.  
  25. <div style="height:500px; width:300px; background-color:#666666;" id="divT"></div>
  26. <input type="button" onclick="$css('divT',{opacity:'0.8',height:'50px',width:'50px'})" value="Probar" />
  27. </body>
  28. </html>
El opacity me cambia bien, pero el tamañono.
Gracias
Salu2
__________________
Half Music - www.halfmusic.com