I have the following code:
<div class="ongoing" style="width: +728px; margin-left: +12480px">
and I would like to use the value of margin-left
for scrolling to a position.
I've used the below code to get the value of width
, but it's not working for margin-left
(because of the hyphen, I assume?):
$("div.ongoing")[0].style.margin-left
How can I get the margin-left
value?
Thanks!
You need to use:
$("div.ongoing")[0].style.marginLeft
or
$("div.ongoing").css("marginLeft");//or .css("margin-left");
试试这个$('div.ongoing')。css('margin-left')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.