Ver Mensaje Individual
  #4 (permalink)  
Antiguo 24/09/2014, 10:14
Avatar de America|UNK
America|UNK
 
Fecha de Ingreso: noviembre-2006
Ubicación: Piura - Perú
Mensajes: 582
Antigüedad: 17 años, 5 meses
Puntos: 56
Respuesta: ¿Onclick con doble función?

Algo más optimizado:

Código Javascript:
Ver original
  1. document.getElementById("contenido").onclick = function(){
  2.         this.style.right = (getComputedStyle(this).getPropertyValue("right").match(/^0/) ? -150 : 0) + "px";
  3. }

Demo: http://jsfiddle.net/wZVanG/jep3msb7/

Por qué getComputedStyle?: this.style.right te mostrará undefined si el elemento HTML no tiene ningún estilo asignado por el atributo style=""

Con jQuery puedes reducir aún más.
__________________
/* El que atiende, entiende..., el que entiende, aprende!.
Desarrollo Web Freelance, Contactar */