mardi 7 février 2017

javascript, offsetTop, offsetBottom

Vote count: 0

i have a paragraph tag in my html id is move, i am trying to move the p tag to slowing fall down while on page load. but my code is not working.......

var speed = 12;

var direction = 1;

var getParagraph = document.getElementById("move");

getParagraph.onmouseover = moving;

function moving(){

var bo = getParagraph.offsetHeight;

var boTop = getParagraph.offsetTop;

var boBottom = boTop + bo;

 // When right side of the box goes too far - change direction:

        if (boBottom > document.body.offsetHeight) {
            direction = -1;
        }
        // When left side of the box goes too far - change direction:

        if (boTop < 0) {

            direction = 1;
        }
        // Recalculate position:
        getParagraph.style.Top = (boTop + speed * direction)

}

asked 45 secs ago

Let's block ads! (Why?)



javascript, offsetTop, offsetBottom

Aucun commentaire:

Enregistrer un commentaire