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

Michael M.
  • 10,486
  • 9
  • 18
  • 34
Brainmaniac
  • 2,203
  • 4
  • 29
  • 53

1 Answers1

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

Michael M.
  • 10,486
  • 9
  • 18
  • 34