I tried to rotate an element by changing the CSS using this code:

elem.style.-moz-transform:rotate(45deg);

It didn't work, and yes, I'm using firefox to test it.
How should this be done?

Recommended Answers

All 9 Replies

Yeah I know that's how you do it in CSS. I was wondering how to phrase that in JavaScript.

Is there really no way to do it in plain JavaScipt, without jquery?

jQuery is just a JavaScript library. The JavaScript syntax should be : object.style.transform="rotate(45deg)"

Thank you!
That's the answer I was looking for.
But what about the -moz-?

Yea, sorry missed the Firefox detail. For Firefox, try...

document.getElementById('elementID').style.MozTransform = 'rotate(45deg)';

Thanks a bunch! Worked like a charm.

great to hear. feel free to mark the thread as solved if you do not require any other help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.