lundi 29 juillet 2019

How to fit getElementById.style within a condition block?

Really need help to understand what is wrong in that piece of code. Basically, if the block has this specific parameter satisfied (in that case left: -1200px), then it does move. In the other case it should stay at its place.

Here it is for the js:

function getReg() {
    var u = document.getElementById('greetings')
    var v = document.getElementById('createaccount')
    if (v.style.left == "-1200px") {
        u.animate([{left: '100px'},{left: '-1200px'}], {duration: 1000, fill: "forwards", easing: "ease"});
        v.animate([{left: '-1200px'},{left: '100px'}], {duration: 1000, fill: "forwards", easing: "ease"});
    } else {
        u.animate([{left: '100px'},{left: '100px'}], {duration: 1000, fill: "forwards", easing: "ease"});
        v.animate([{left: '-1200px'},{left: '-1200px'}], {duration: 1000, fill: "forwards", easing: "ease"});
    }
}

Thank you very much in advance

Aucun commentaire:

Enregistrer un commentaire