1

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

Brainmaniac
  • 2,115
  • 2
  • 22
  • 43

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.
  • 288
  • 2
  • 12