Gwouten
Gwouten

Reputation: 7

How can I find the value of inline margin-left using jquery

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!

Upvotes: 0

Views: 829

Answers (2)

Milind Anantwar
Milind Anantwar

Reputation: 82231

You need to use:

 $("div.ongoing")[0].style.marginLeft

or

 $("div.ongoing").css("marginLeft");//or .css("margin-left");

Upvotes: 3

Aakash
Aakash

Reputation: 1791

Try this $('div.ongoing').css('margin-left')

Upvotes: 0

Related Questions