Jagr
Jagr

Reputation: 502

Image not working when clicked

When you click a navigation item at the top of the screen, a blank div pops up with a huge "x" image that when clicked, the x image is suppose to close the blank div and everything else. For "jobs, contact, press, and legal" it doesn't work when clicked but for "support" it works perfectly. I put the code side by side to see errors, copy the support code and paste for others... basically everything imaginable for 1-2hours. I found a glitch that when you open the "support" first then close it out and open another one, the x image works but I don't know why. Here is my html and the rest of the code will be uploaded to codeine

demo: http://codepen.io/anon/pen/dvzgrY

<html>
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link href="https://fonts.googleapis.com/css?family=Nunito:700" rel="stylesheet">
        <link href="https://fonts.googleapis.com/css?family=Baloo" rel="stylesheet">
        <link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet">
        <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> 
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
        <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
        <link rel="stylesheet" type="text/css" href="magicstyle.css">
        <body>
            <!-- Section for Jobs Popup -->
            <div id="job-popup">
                <div class="x-div1"><img class="x-icon1" id="fadeX1" src="Pictures/web%20x%20icon%20white.png"></div>
                <div id="job-content"> 
                    <h1 id="jobWords"></h1>
                </div>
            </div>
            <!-- Section for Contact Popup -->
            <div id="contact-popup">
                <div class="x-div2"><img class="x-icon2" id="fadeX2" src="Pictures/web%20x%20icon%20white.png"></div>
                <div id="contact-content">
                    <h1 id="contactWords"></h1>
                </div>
            </div>  
            <!-- Section for Press Popu -->
             <div id="press-popup">
                <div class="x-div3"><img class="x-icon3" id="fadeX3" src="Pictures/web%20x%20icon%20white.png"></div>
                <div id="press-content"> 
                    <h1 id="pressWords"></h1>  
                </div>
            </div>
            <div id="legal-popup">
                <div class="x-div4"><img class="x-icon4" id="fadeX4" src="Pictures/web%20x%20icon%20white.png"></div>
                <div id="legal-content">
                    <h1 id="legalWords"></h1>
                </div>             
            </div> 
            <div id="support-popup">
                <div class="x-div5"><img class="x-icon5" id="fadeX5" src="Pictures/web%20x%20icon%20white.png"></div>
                <div id="support-content">                   
                    <h1 id="supportWords"></h1>                    
                </div>             
            </div>         
            <div id="top-bar">
                <a class="burger-nav"></a>
                <div id="nav-menu">
                    <span id="job">Jobs</span>
                    <span id="contact">Contact</span>
                    <span id="press">Press</span>
                    <span id="legal">Legal</span>
                    <span id="support">Support</span>                       
                </div>
            </div>
            <div id="container">
                <div id="name-div">
                    <h1 id="name">Open Touch</h1>
                </div>
                <ul class="bubbles">              
                    <li id="firstCircle"></li>
                    <li id="secondCircle"></li>
                    <li id="thirdCircle"></li>
                    <li id="fourthCircle"></li>
                    <li id="fifthCircle"></li>
                    <li id="sixthCircle"></li>             
                </ul>
            </div>
        </body>
    </head>
</html>

Any help will be greatly appreciated :D

Upvotes: 0

Views: 62

Answers (1)

D_S_B
D_S_B

Reputation: 208

The problem is that all your popup containers (job-popup, contact-popup, etc) are positioned absolutely at the same location with the same z-index. Since the support-popup is last in your html, it's hiding all the popup containers underneath it. You are never actually clicking on the other x-icons (only on the top support one), and therefore, the click handlers are not getting triggered.

For a quick fix, you could update the z-index, in your nav click handlers. For example:

$("#job").click(function() {
    $("#job-popup").fadeIn(300);
    $("#job-popup").css({'z-index': 15});
    $("#job-content").fadeIn(300); 
    $("#jobWords").fadeIn(300); 
    $(".x-icon1").fadeIn(300); 
    $("#name").fadeOut(300); 
    $("#container").css("-webkit-filter", "blur(10px)");
}

and then move it back down here

 $(".x-icon1").click(function() {
     $("#job-popup").fadeOut(); 
     $("#job-popup").css({'z-index': 10});
     $("#job-content").fadeOut(); 
     $("#jobWords").fadeOut(); 
     $(".x-icon1").fadeOut();  
     $("#name").fadeIn();  
     $("#container").css("-webkit-filter", "blur(0px)");
}

and then replicate this for all your click handlers.

But you should also consider refactoring your html/css, since the structure is incorrect (body within head, for example), and a lot of the css is probably unnecessary.

Upvotes: 1

Related Questions