0

I just picked up javascript and jquery.

This is my HTML code:

<img id='wheel' width="400" height="400" src="wheel.png"/>

Then I use jQuery to get the object.

var $img = $('#wheel');

Then I set a new CSS property.

$img.css('transform', 'rotate(90deg)');

When I ask for the property again I get the computed style (as I should).

console.log($img.css('transform'));

In this case the computed style is:

matrix(6.12323e-17, 1, -1, 6.12323e-17, 0, 0)

I don't know why I would want that, can I convert it to "normal" style? Or should I just use getAttribute and setAttribute instead of using jquery in this case?

gel
  • 281
  • 3
  • 19
  • You get the computed style as that's what the browser uses (note this is due to the CSS/JS engine of the browser, and not anything to do with jQuery). You could use `attr()` instead, but that's an ugly hack that will probably lead to more problems than it solves. – Rory McCrossan Nov 09 '16 at 14:10
  • Thanks for the reply, but isnt $img[0].getAttribute('style') better then? – gel Nov 09 '16 at 14:11
  • http://stackoverflow.com/questions/8601209/fetch-the-css-value-of-transform-directly-using-jquery – DaniP Nov 09 '16 at 14:12
  • 1
    http://stackoverflow.com/questions/8270612/get-element-moz-transformrotate-value-in-jquery/11840120#11840120 – DaniP Nov 09 '16 at 14:12

0 Answers0