I want to translate a div element using javascript. I tried multiple ways, listed below (item is the element):
item = document.getElementById("myDiv");
var x, y
x = y = 20
// doesn't change anything
item.style.translate = "translate(" + x + "px," + y + "px)";
// only works on canvas
try {
item.translate(x, y);
} catch (e) {
console.log(e)
}
<div id=myDiv>Text...</div>
How can I move the div without resorting to CSS (I want to do this to multiple elements, differently)?