My click on login is not working on webpage

I worked on a website for a client in wordpress. I wrote HTML, CSS and Javascript to click on login button and a dropdown menu pulls down. The onclick function was working but it is not now. I don’t see why it is not working. The website is http://outsourceyourjobsearch.com/builder/. I have to write all the code on one file due to the theme he chose for his website.

<!DOCTYPE html> 
<html>
<head>
    <style>
        .dropbtn { 
            background-color: #4CAF50; 
            color: white; 
            padding: 16px;
            font-size: 16px; 
            border: none; 
            cursor: pointer;
        } 

        .dropbtn:hover, .dropbtn:focus { 
            background-color: #3e8e41; 
        } 

        .dropdown {
            position: relative; 
            float: right;
            margin-right: 200px; 
        } 

        .dropdown-content { 
            display: none;
            position: absolute; 
            background-color: #f9f9f9;
            min-width: 160px; 
            overflow: auto; 
            box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);'
        }

        .dropdown-content a {
            color: black; 
            padding: 12px 16px;
            text-decoration: none; 
            display: block;
        }

        .dropdown a:hover {
            background-color: #f1f1f1
        }

        .show {
            display:block;
        }

        .button:hover span:after { 
            opacity: 1; right: 0;
        }

        .button span { 
            cursor: pointer;
            display: inline-block;
            position: relative;
            transition: 0.5s; 
        } 

        .button {
            width: 131px;
            background-color: white;
            color: black;
            border: 2px solid #008CBA;
            font-size: large;
            margin-top: 8px;
            margin-right: 75px;
        } 

        .login-form{
            width: 300px;
            padding-top: 5px;
            padding-right: 5px;
            padding-bottom: 5px;
            padding-left: 5px;
        } 

        input{ 
            font-size: large;
            margin-top: 8px; 
        }

        .register { 
            margin-left: 25px;
            text-decoration: none; 
            font-size: small; 
            width: 80px;
        }

        .password{
            margin-left: 126px; 
            margin-top: -69px; 
            text-decoration: none; 
            font-size: small;
        } 

        a:link { 
            text-decoration: none;
        } 

        a:visited { 
            text-decoration: none;
        }

        a:active {
            text-decoration: underline;
        }

        center{
            display: inline;
            padding-left: 10px;
            padding-right: 10px;
        }

    </style>
    </head> 

    <body>
       <div class="dropdown">
           <button onclick="myFunction()" class="dropbtn" >
            Log In
        </button> 
        <div id="myDropdown" class="dropdown-content"> 
            <form class="login-form"> 
                <input type="text" placeholder="username"/> 
                <input type="password" placeholder="password"/>
                <button class ="button">login</button> 
                <div class = "center">
                    <p><a     href="http://outsourceyourjobsearch.com/membership-account/membership-levels/" class="register">Register</a></p> <p><a href="http://outsourceyourjobsearch.com/wp-login.php?action=lostpassword" class="password">Forgot Password?</a></p>
                </div>      
            </form> 
        </div> 
    </div> 

    <script>
    /* When the user clicks on the button, toggle between hiding and showing the dropdown content */
    function myFunction() {
        document.getElementById("myDropdown").classList.toggle("show");
    }

    /* Close the dropdown if the user clicks outside of it */
    window.onclick = function(event) {
        if (!event.target.matches('.dropbtn')) {

            var dropdowns = document.getElementsByClassName("dropdown-content");
            var i;
            for (i = 0; i < dropdowns.length; i++) {
                var openDropdown = dropdowns[i];
                if (openDropdown.classList.contains('show')) {
                    openDropdown.classList.remove('show');
                }
            }
        }
    }
    </script>

</body> 
</html>

Related posts

2 comments

  1. Structure which you used in your website is not correct. I checked it and in the block which you used that its html is:

    <div class="et_pb_fullwidth_code et_pb_module  et_pb_fullwidth_code_0">
                <!DOCTYPE html> <html> <head> <style> .dropbtn { background-color: #4CAF50; color: white; padding: 16px; font-size: 16px; border: none; cursor: pointer; } .dropbtn:hover, .dropbtn:focus { background-color: #3e8e41; } .dropdown { position: relative; float: right; margin-right: 200px; } .dropdown-content { display: none; position: absolute; background-color: #f9f9f9; min-width: 160px; overflow: auto; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);' } .dropdown-content a { color: black; padding: 12px 16px; text-decoration: none; display: block; } .dropdown a:hover { background-color: #f1f1f1 } .show { display:block; } .button:hover span:after { opacity: 1; right: 0; } .button span { cursor: pointer; display: inline-block; position: relative; transition: 0.5s; } .button { width: 131px; background-color: white; color: black; border: 2px solid #008CBA; font-size: large; margin-top: 8px; margin-right: 75px; } .login-form{ width: 300px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; } input{ font-size: large; margin-top: 8px; } .register { margin-left: 25px; text-decoration: none; font-size: small; width: 80px; } .password{ margin-left: 126px; margin-top: -69px; text-decoration: none; font-size: small; } a:link { text-decoration: none; } a:visited { text-decoration: none; } a:active { text-decoration: underline; } center{ display: inline; padding-left: 10px; padding-right: 10px; } </style> </head> <body> <div class="dropdown"> <button onclick="myFunction()" class="dropbtn" > Log In </button> <div id="myDropdown" class="dropdown-content"> <form class="login-form"> <input type="text" placeholder="username"/> <input type="password" placeholder="password"/> <button class ="button">login</button> <div class = "center"> <p><a href="http://outsourceyourjobsearch.com/membership-account/membership-levels/" class="register">Register</a></p> <p><a href="http://outsourceyourjobsearch.com/wp-login.php?action=lostpassword" class="password">Forgot Password?</a></p> </div> </form> </div> </div> <script> /* When the user clicks on the button, toggle between hiding and showing the dropdown content */ function myFunction() { document.getElementById("myDropdown").classList.toggle("show"); } // Close the dropdown if the user clicks outside of it window.onclick = function(event) { if (!event.target.matches('.dropbtn')) { var dropdowns = document.getElementsByClassName("dropdown-content"); var i; for (i = 0; i < dropdowns.length; i++) { var openDropdown = dropdowns[i]; if (openDropdown.classList.contains('show')) { openDropdown.classList.remove('show'); } } } } </script> </body> </html>
            </div>
    

    You have <!DOCTYPE html> <html> <head> inside a <div> tag and should not have that.

Comments are closed.