我正在尝试将我的 var 添加到此字符串:
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'
});
关于javascript - 使用 jQuery 的简单字符串和变量问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1578131/