String simples e problema variável usando jQuery
-
21-09-2019 - |
Pergunta
Estou tentando adicionar meu VAR a esta string:
var liPad = 20;
$(this).css({'width' : width , 'height' : height, 'padding' : "'0px' + liPad + 'px'"});
Para fazer funcionar assim:
$(this).css({'width' : width , 'height' : height, 'padding' : '0 20px'});
Não consigo descobrir como fazê -lo funcionar.
Qualquer ajuda seria apreciada.
Solução
Isso deve funcionar:
$(this).css({
'width': width,
'height': height,
'padding': '0 ' + liPad + 'px'
});
Outras dicas
Eu acho que a questão é que você precisava de um espaço onde está o yyyyyyy. Era 0px20px
preenchimento ': "' 0pxyyyyyyy ' + lipad +' px '"});
O seguinte deve funcionar:
var liPad = 20;
$(this).css({'width' : width , 'height' : height, 'padding' : "'0px ' + liPad + 'px'"});
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow