Foros del Web » Programando para Internet » Javascript »

cambiar background-position

Estas en el tema de cambiar background-position en el foro de Javascript en Foros del Web. Intente hacer esto.. @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código HTML: Ver original document.getElementById(13).background-position=-100 Pero no funciona :(...
  #1 (permalink)  
Antiguo 24/02/2010, 10:29
Avatar de angel1993  
Fecha de Ingreso: octubre-2009
Mensajes: 752
Antigüedad: 14 años, 6 meses
Puntos: 22
cambiar background-position

Intente hacer esto..
Código HTML:
Ver original
  1. document.getElementById(13).background-position=-100
Pero no funciona :(
  #2 (permalink)  
Antiguo 24/02/2010, 10:33
Avatar de jackson666  
Fecha de Ingreso: noviembre-2009
Ubicación: Buenos Aires, Argentina
Mensajes: 1.971
Antigüedad: 14 años, 5 meses
Puntos: 65
Respuesta: cambiar background-position

Y el problema es que un id no puede ser numerico.... recuerda que un id es un string!

Debe empezar obligatoriamente con una letra o un guion bajo. Ademas, como haces que se ejecute esa linea?
__________________
HV Studio
Diseño y desarrollo web
  #3 (permalink)  
Antiguo 24/02/2010, 10:39
Avatar de angel1993  
Fecha de Ingreso: octubre-2009
Mensajes: 752
Antigüedad: 14 años, 6 meses
Puntos: 22
Respuesta: cambiar background-position

Tio tengo muchas id con numeros y funcionan el codigo es este
Código HTML:
Ver original
  1. <table width="300" border="0" cellpadding="0" cellspacing="0" id="13" style="   background-position: -303px;background-image: url(img/web/fpuntos.gif);background-color: #000000;background-repeat:  no-repeat;">
  2.     <tr><td><table border="0" cellpadding="0" cellspacing="0">
  3.         <tr>
  4.       <td width="30" height="23" ><img name="" src="img/web/punto.png" width="30" height="23" alt="" /></td>
  5.       <td width="30" ><img onclick="javascript:document.getElementById(13).background-position='-100" src="img/web/punto.png" width="30" height="23" alt="" /></td>
  6.       <td width="30" ><img name="" src="img/web/punto.png" width="30" height="23" alt="" /></td>
  7.       <td width="30" ><img name="" src="img/web/punto.png" width="30" height="23" alt="" /></td>
  8.       <td width="30" ><img name="" src="img/web/punto.png" width="30" height="23" alt="" /></td>
  9.       <td width="30" ><img name="" src="img/web/punto.png" width="30" height="23" alt="" /></td>
  10.       <td width="30" ><img name="" src="img/web/punto.png" width="30" height="23" alt="" /></td>
  11.       <td width="30" ><img name="" src="img/web/punto.png" width="30" height="23" alt="" /></td>
  12.       <td width="30" ><img name="" src="img/web/punto.png" width="30" height="23" alt="" /></td>
  13.       <td width="30" ><img src="img/web/punto.png" width="30" height="23" alt="" /></td>
  14.     </tr></table></td></tr></table>
  #4 (permalink)  
Antiguo 24/02/2010, 11:01
Avatar de jackson666  
Fecha de Ingreso: noviembre-2009
Ubicación: Buenos Aires, Argentina
Mensajes: 1.971
Antigüedad: 14 años, 5 meses
Puntos: 65
Respuesta: cambiar background-position

Que raro... Entonces te falta el 'px', asi:

Código Javascript:
Ver original
  1. onclick="javascript:document.getElementById(13).background-position='-100px"
__________________
HV Studio
Diseño y desarrollo web
  #5 (permalink)  
Antiguo 24/02/2010, 11:09
Avatar de angel1993  
Fecha de Ingreso: octubre-2009
Mensajes: 752
Antigüedad: 14 años, 6 meses
Puntos: 22
Respuesta: cambiar background-position

que va tio no funciona :(
  #6 (permalink)  
Antiguo 24/02/2010, 11:12
Avatar de JavierB
Colaborador
 
Fecha de Ingreso: febrero-2002
Ubicación: Madrid
Mensajes: 25.052
Antigüedad: 22 años, 2 meses
Puntos: 772
Respuesta: cambiar background-position

Hola angel1993

Prueba así:

Código javascript:
Ver original
  1. onclick="document.getElementById('13').style.backgroundPosition='-100px'"

Saludos,
  #7 (permalink)  
Antiguo 24/02/2010, 14:01
Avatar de angel1993  
Fecha de Ingreso: octubre-2009
Mensajes: 752
Antigüedad: 14 años, 6 meses
Puntos: 22
Respuesta: cambiar background-position

al final e creado varios estilos y cambio de estilo..
Gracias a todos

Etiquetas: Ninguno
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 07:03.