Javascript 使用jQuery的简单字符串和变量问题
我正在尝试将我的变量添加到此字符串:Javascript 使用jQuery的简单字符串和变量问题,javascript,string-concatenation,Javascript,String Concatenation,我正在尝试将我的变量添加到此字符串: var liPad = 20; $(this).css({'width' : width , 'height' : height, 'padding' : "'0px' + liPad + 'px'"}); 要使其像这样工作: $(this).css({'width' : width , 'height' : height, 'padding' : '0 20px'}); 我不知道该怎么做 任何帮助都将不胜感激。这应该可以: $(this).css({
var liPad = 20;
$(this).css({'width' : width , 'height' : height, 'padding' : "'0px' + liPad + 'px'"});
要使其像这样工作:
$(this).css({'width' : width , 'height' : height, 'padding' : '0 20px'});
我不知道该怎么做
任何帮助都将不胜感激。这应该可以:
$(this).css({
'width': width,
'height': height,
'padding': '0 ' + liPad + 'px'
});
var liPad = 20;
$(this).css({'width' : width , 'height' : height, 'padding' : "'0px ' + liPad + 'px'"});
我认为问题在于,您需要一个yyyyyy所在的空间。它是0px20px 填充“:”'0pxyyyyyyy'+liPad+'px'}) 以下方面应起作用:
$(this).css({
'width': width,
'height': height,
'padding': '0 ' + liPad + 'px'
});
var liPad = 20;
$(this).css({'width' : width , 'height' : height, 'padding' : "'0px ' + liPad + 'px'"});