Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/07/2009, 06:11
Avatar de Legoltaz
Legoltaz
 
Fecha de Ingreso: agosto-2008
Mensajes: 325
Antigüedad: 15 años, 9 meses
Puntos: 6
jQuery: Problemas con uso de variable

Hola a tod@s, hoy he empezado con jQuery, y ya me ha surgido esta duda: ¿cómo puedo utilizar una variable JavaScript (ej: var myvar = 50;) en jQuery?

Código JavaScript:
Ver original
  1. var trueWidth = this.width;
  2. var trueHeight = this.height;
  3. $(this).animate({width:trueWidth,height:trueHeight},"slow");

Necesito asignarle al width y height del animate las variables trueWidth y trueHeight respectivamente, pero no me funciona del modo que ahí muestro. ¿Algún consejo? (repito que hoy mismo he empezado con jQuery y estoy totalmente verde ).

Otra pregunta: ¿Cómo puedo acceder a las propiedades de un objeto en jQuery? (ej: $("#elemento").width)?

Última edición por Legoltaz; 25/07/2009 a las 07:16