Javacadabra
Javacadabra

Reputation: 5758

Retrieve css property scaleX using JQuery

I am trying to print out the properties of a particular div using JQuery. I would like the various css properties to appear in an information panel on the screen.

I am trying to display scaleX but having a lot of difficulty. This is my code currently:

//Size Control
$("#slider").change(function () {
    size = $("#slider").val();
    //Update the size of box while dragging
    b1.css({
        "-webkit-transform": "scaleX(" + size / 10 + ") scaleY(" + size / 10 + ") rotate(" + rotation + "deg) rotateX("+ rotateX + "deg) rotateY("+ rotateY + "deg) skew("+ skewX + "deg," + skewY + "deg)",
    });

    $("#sizeInfo").text("Size: " + b1.css("-webkit-transform"));

});

HTML

 <div id="b1"></div>

Output in info panel

matrix3d(-0.6998933866094739, -0.012216684506098372, 0.0000000000000001224646799147353, 0, 0.012216684506098542, -0.6998933866094739, 0.0000000000000001224646799147353, 0, 0.00000000000000008421610720791067, 0.00000000000000008720833192322797, 1, 0, 0, 0, 0, 1)

Any help is much appreciated.

Upvotes: 1

Views: 516

Answers (1)

Explosion Pills
Explosion Pills

Reputation: 191749

jQuery's .css wraps window.getComputedStyle which uses the computed style rather than the raw style information. You can use the style property on the element to get the actual string:

b1.get(0).style.WebkitTransform

Upvotes: 2

Related Questions