2009-10-16 9 views
0

Je suis en train d'ajouter mon var à cette chaîne:Chaîne simple et problème variable en utilisant jQuery

var liPad = 20; 

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

Pour le faire fonctionner comme ceci:

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

ne peux pas comprendre comment fais-le fonctionner.

Toute aide serait appréciée.

Répondre

6

Cela devrait fonctionner:

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

qui fonctionne très bien. Merci! – Dom

+0

Vous êtes les bienvenus :) – moff

1

Je pense que le problème est que vous avez besoin d'un espace où le yyyyyyy est. il était 0px20px

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

Ce qui suit devrait fonctionner:

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