2

I am removing jQuery and need to be able to add these css transform attributes to an element using vanilla js:

-ms-transform: scale(1.05); /* IE 9 */
-webkit-transform: scale(1.05); /* Safari */
transform: scale(1.05);

Today I have the code changed with jQuery like:

$(".my-class").css({
    '-ms-transform': 'scale(1.05)', /* IE 9 */
    '-webkit-transform': 'scale(1.05)', /* Safari */
    'transform': 'scale(1.05)',
})

The problem is to do something like:

$element.style.-ms-transform = 'scale(1.05)'

But this does not work 👆

2
  • Damn, I will just not use it :D .... it seems most major browser supports the transform Commented May 26, 2022 at 21:37
  • Were you every able to resolve this issue? If so, did my answer below help you? Commented Dec 27, 2022 at 7:07

1 Answer 1

3

Try doing it like this:

$element.style["-ms-transform"] = 'scale(1.05)'

Remember that you can access objects like arrays with strings. W3Schools page on Objects

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.