Marinescu Vlad Marinescu Vlad - 1 year ago 68
jQuery Question

Getting the transform class property of an element in Javascript

I want to make two events depends on a scale property of a menu. So this is my


<div class="starting-point">
<span class="" style="transform: scaleX(1) scaleY(1); height: 2760.56px; width: 2760.56px; top: -1380.28px; left: -1380.28px;"></span>

How can I get the
transform: scaleX(1) scaleY(1)
into a variable? Sometimes the values are
scaleX(0) scaleY(0)
and I want to perform different actions depending on these values.

I assigned
class to that span and I tried this, but there is no scale or something useful in the results.

var style = getComputedStyle(document.getElementsByClassName('dddd')[0])

Thanks a lot.

Answer Source

Here you go:

var style = getComputedStyle(document.getElementsByClassName('dddd')[0], null);



If you prefer not to add the class, you can change your code like this:

var style = getComputedStyle(document.querySelector('.starting-point span'), null);

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download