3
For example, I have a script that picks up mouse coordinates:
function posicaoMouse(ev){
ev.preventDefault();
var x = ev.clientX;
var y = ev.clientY;
console.log(x);
console.log(y);
}
And I would like the top and the left to be defined by the variables xand y of Function posicaoMouse, it is possible?
<span class="duvida" id="duvida2" style="position: absolute; top:'$x' left:'$y'"> teste </span>
With CSS, no. What you can do is change these values via JS, with
element.style.top = yandelement.style.left = x, for example.– Woss
I understood, there I define for example
var teste= $("#teste");and then I define howteste = element.style...That’s it??– Sora