Home > Blockchain >  javascript cant read my toggle please help me with it
javascript cant read my toggle please help me with it

Time:04-24

When I try To Function The Hamburger using the code Please help

burger = document.querySelector('.burger')
navbar = document.querySelector('.navbar')
navlist = document.querySelector('.nav-list')


burger.addEventListener('click', ()=>{
navbar.ClassList.toggle('v-class-resp');
nav-list.classlist.toggle('v-class-resp');

})

It Show Me The Error Can't read toggle (reading 'toggle) if someone could help with design please help me

here is the html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="Home.css">
    
    <title>SG Network</title>
    
</head>
<body  >
    
    <nav  >
        <ul >
            <div  style="border: 60px;"> <img src="Add a heading.jpg" alt="Logo"> </div>
            <li> <a href="#HomePage">HomePage</a></li>
            <li> <a href="#About us">About us</a></li>
            <li> <a href="#Buy-Ranks">Buy Ranks</a></li>
            <li> <a href="#Donate">Donate</a></li>
            <li> <a href="#Vote">Vote</a></li>
            <li> <a href="#Discord">Discord</a></li><h1></h1>
        </ul>
        <div >
            <div ></div>
            <div ></div>
            <div ></div>
        </div>
    </nav>
    <section >
<div >
<div > <p >SG NetWork Is A Network blah blah blah blah blah vlah vlah
     vlah blah vlah vlah blah vlah vlah blah vlah vlah blah vlah vlah blah vlah vlah blah vlah
      vlah blah vlah vlah blah vlah vlah blah vlah vlah blah 

            
</p>
<div >
    <button >Vote</button>
    <button >Discord</button>
</div>
 </div>
<div >

    
</div>
</div>

<p>
    <footer >Copyright &copy; All Rights Reserverd</footer>
    </p>

    <script src="resp.js">
    </script>
</body>
</html>

help would be apprieciated enter image description here

Please Help This Is the page

CodePudding user response:

JavaScript is a case-sensitive language, meaning you can't type ClassList, you can't type classlist, you have to type classList. Also, you can't type nav-list.classList, you have to type navlist.classList because you defined it as navlist, not nav-list and - is not allowed in variable names.

  • Related