'document.getElementById().style.transition does not return any value

I have an div element with the id 'he' and its css properties are position: fixed; and left: 0;

javascript:

    var dief = document.getElementById('he');

//this gets a random value within the dimensions of the page so that the object does not move
    var mh = Math.floor(Math.random() * window.innerHeight);
//this should set the transition to be mh/50, but it does not apply
    dief.style.transition = "transition: left "+mh/50+"s linear;";
//this sets the position 
    dief.style.left = mh+"px";


Solution 1:[1]

You dont need the 'transition' property and the semicolon in the style attributes.

Untested:

dief.style.transition = "left "+mh/50+"s linear";

Take a look: https://www.w3schools.com/jsref/prop_style_transition.asp

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tobi360