• Could someone please explain this piece of code for me:

    var bottomPos1 = $('#top-slider').outerHeight(true)-$("#main-header").height()-15;

    I want to change the position.

    Its for the placement of a image on my home page, but im not good with JS so I dont know what to do to change the position of my image.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter dcxs

    (@dcxs)

    This also seems related:

    $("#top-slider").append('<img class="stamp">');
        $(".stamp").attr("src",templateDir+"/img/Klarna_stamp.png");
    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    var bottomPos1 = $(‘#top-slider’).outerHeight(true)-$(“#main-header”).height()-15;

    • Get the height of the slider (a)
    • Get the height of the header (b)
    • Subtract the height of the slider (a) from the height of the header (b)
    • Subtract 15 from the total sum (c)
    (a - b) - c
    Thread Starter dcxs

    (@dcxs)

    Thank you! Never would have guessed that. So if I wanted to move the position upward, how would I go about doing that?

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    You can change the height of the header, change the height of the slider or modify that code. Or rewrite your own.

    Thread Starter dcxs

    (@dcxs)

    I see, I guess in this case Im not sure where the #main-header is located. I have only done PHP and CSS programming before.

    I cant find the #main-header in the JS file atleast.

    Thread Starter dcxs

    (@dcxs)

    I think I dont want to change the #main-header, because it might effect other things on the site. I just wish there was a simpler way to write the code.

    Thread Starter dcxs

    (@dcxs)

    Actully playing with the code this seems to be the only relevant code:

    $("#top-slider").append('<img class="stamp">');
    $(".stamp").attr("src",templateDir+"/img/Klarna_stamp.png");

    So I wrote the wrong code in the beginning. So how can I move the image further up with this code?

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Position further up.. We need to see the page you’re talking about.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Simple Javascript question’ is closed to new replies.