Jump to content

Help building site - Slider and dropdown problem


Sonalk

Recommended Posts

First of all, I'm no way near any skilled "programmer" or website builder, I mostly just copy things and modify the styles and stuff!  So this is probably a nooby question, you have been warned.

I've this website I'm building for a school project and I've a few problems left and I've given up trying to fix them, I need to start working on other stuff.

First of all so am I trying to get this slider between the three pictures and the navigation bar in the supposedly start page, but the animation disappear when you put it in and I don't think the autoplays work either. This is the main thing I'm trying to do.

Secondly,  When you go on mobile view and press the dropdown menu it doesn't seem to find the script, which i don't understand why.

In the header I have

<script src="/online-store-header/js/flertdown.js"></script>

and the body I've the code

<a href="javascript:void(0);" style="font-size:25px;position: absolute; top: 65px; right: 0; border: 0;" class="icon" onclick="specificName()"></a>

The console returns this error:

Uncaught TypeError: Cannot read property 'className' of null
    at specificName (flertdown.js:3)
    at HTMLAnchorElement.onclick (final.html:195)

Dropdown js code

Any help would be really appreciated, i really need to be done this site soon :)) And I'm really sorry if the index file is totally chaos, elements seems to have a life of their own and come back and reproduce to multiple of the same element after I've deleted them, I've lost control of what i've created (or copied)

 

Edited by Sonalk
Link to comment
Share on other sites

Hi there Sonalk!

In terms of your second half:

This one is a really easy one to overlook. I don't blame you for getting tripped up on this one

function specificName() {
    var x = document.getElementById("myTopnav");
    if (x.className === "topnav") {
        x.className += " responsive";
    } else {
        x.className = "topnav";
    }
}

Your JavaScript is looking for an element with an `id` attribute of `myTopnav` but your `<a>` tag seems to be missing an id attribute altogether (Which I assume is the tag you want to retrieve).

 

If you add an id that matches your JavaScript, I reckon you might get a better result.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...