jquerylightboxlightbox2

jQuery Lightbox2 not working


I don't know why LightBox is not working. When I click on the image, it goes to the link of the page, rather than have the "lightbox" fade-in to show the image. I console.logged and I get no error messages.

P Gallery | View Portfolio

    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="dist/css/lightbox.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script src="js/script.js"></script>
    <script src="dist/js/lightbox.js"></script>

</head>


        <section>
            <div class="container">
                <h1 id="heading">All Projects</h1>
                <ul id="gallery">
                    <li class="design" ><a href="img/web1.jpg" data-lightbox="example-set" data-title="Project 1" data-desc="abc"><img src="img/web1.jpg"></a></li>
                    <li class="programming" ><a href="img/web2.jpg" data-lightbox="example-set"  data-title="Project 1" data-desc="abc"><img src="img/web2.jpg"></a></li>
                    <li class="cms" ><a href="img/web3.jpg" data-lightbox="example-set"  data-title="Project 1" data-desc="abc"><img src="img/web3.jpg"></a></li>
                    <li class="cms" ><a href="img/web4.jpg" data-lightbox="example-set"  data-title="Project 1" data-desc="abc"><img src="img/web4.jpg"></a></li>
                    <li class="design cms programming" ><a href="img/web5.jpg" data-lightbox="example-set"  data-title="Project 1" data-desc="abc"><img src="img/web5.jpg"></a></li>
                    <li class="design cms programming" ><a href="img/web6.jpg" data-lightbox="example-set"  data-title="Project 1" data-desc="abc"><img src="img/web6.jpg"></a></li>
                </ul>
            </div>
        </section>

Solution

  • Load the lightbox javascript file at the end of your body tag. Worked for me. apparently lightbox need the DOM ready to parse the images/links.