views:

107

answers:

2

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.

+6  A: 

This should work:

$(this).css({
    'width': width,
    'height': height,
    'padding': '0 ' + liPad + 'px'
});
moff
That is working just fine. Thanks you!
Dom
You're welcome :)
moff
+1  A: 

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'"});
easement