문제

I'm trying to add my var to this string:

var liPad = 20;

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

To make it work like this:

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

Can't figure out how to make it work.

Any help would be appreciated.

도움이 되었습니까?

해결책

This should work:

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

다른 팁

I think the issue is that you needed a space where the yyyyyyy is. it was 0px20px

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

The following should work:

var liPad = 20;
$(this).css({'width' : width , 'height' : height, 'padding' : "'0px ' + liPad + 'px'"});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top