Pregunta

Estoy intentando añadir mi var a esta cadena:

var liPad = 20;

$(this).css({'width' : width , 'height' : height, 'padding' : "'0px' + liPad + 'px'"});

Para hacer que funcione de esta manera:

$(this).css({'width' : width , 'height' : height, 'padding' : '0 20px'});

No se puede encontrar la manera de hacer que funcione.

Cualquier ayuda sería apreciada.

¿Fue útil?

Solución

Esto debería funcionar:

$(this).css({
    'width': width,
    'height': height,
    'padding': '0 ' + liPad + 'px'
});

Otros consejos

Creo que el problema es que se necesita un espacio donde el yyyyyyy es. era 0px20px

padding': " '0pxyyyyyyy' + liPad + 'px'"});

El siguiente debería funcionar:

var liPad = 20;
$(this).css({'width' : width , 'height' : height, 'padding' : "'0px ' + liPad + 'px'"});
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top