So, I'm defining some CSS values with jQuery. I'm defining multiple values like so:
所以,我用jQuery定义了一些CSS值。我正在定义多个值,如下所示:
$('#elementId').css({
height : '60px',
width : '268px',
display : 'block',
float : 'left'
});
Note I'm also adjusting the 'float'. Although it does work, 'float' (obviously) is a datatype, and my editor identifies it a such. I was wondering if there's a more proper way to change the float CSS value, rather than using the reserved float datatype. I suppose this is kind of an OCD issue, but I like to do things right.
注意我也在调整'浮动'。虽然它确实有效,但'浮动'(显然)是一种数据类型,我的编辑器就是这样的。我想知道是否有更合适的方法来更改浮动CSS值,而不是使用保留的float数据类型。我想这是一个强迫症问题,但我喜欢做正确的事情。
Thanks.
1 个解决方案
#1
6
Try wrapping it in inverted commas:
尝试用引号括起来:
$('#elementId').css({
'height': '70px',
'width': '280px',
'display': 'inline-block',
'float': 'left',
});
See this example
看这个例子
#1
6
Try wrapping it in inverted commas:
尝试用引号括起来:
$('#elementId').css({
'height': '70px',
'width': '280px',
'display': 'inline-block',
'float': 'left',
});
See this example
看这个例子