0

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.

2 Answers 2

6

This should work:

$(this).css({
    'width': width,
    'height': height,
    'padding': '0 ' + liPad + 'px'
});
Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.