Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery multiple css values - problems with "float"

Tags:

jquery

css

So, I'm defining some CSS values with jQuery. I'm defining multiple values like so:

$('#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.

Thanks.

like image 207
Nigel M. Avatar asked Feb 03 '26 13:02

Nigel M.


1 Answers

Try wrapping it in inverted commas:

$('#elementId').css({
    'height': '70px',
    'width': '280px',
    'display': 'inline-block',
    'float': 'left',
});

See this example

like image 73
jacktheripper Avatar answered Feb 06 '26 08:02

jacktheripper



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!