Chaîne simple et problème variable en utilisant jQuery
-
21-09-2019 - |
Question
Je suis en train d'ajouter mon var à cette chaîne:
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'});
Impossible de savoir comment le faire fonctionner.
Toute aide serait appréciée.
La solution
Cela devrait fonctionner:
$(this).css({
'width': width,
'height': height,
'padding': '0 ' + liPad + 'px'
});
Autres conseils
Je pense que le problème est que vous avez besoin d'un espace où le yyyyyyy est. il était 0px20px
padding »: " '0pxyyyyyyy' + + l'iPad 'px'"});
Ce qui suit devrait fonctionner:
var liPad = 20;
$(this).css({'width' : width , 'height' : height, 'padding' : "'0px ' + liPad + 'px'"});
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow