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.

Foi útil?

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
scroll top