Question

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.

Was it helpful?

Solution

This should work:

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

OTHER TIPS

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'"});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top