user2734700 user2734700 - 18 days ago 4
jQuery Question

jQuery colorbox plugin not working

I am making a kind of gallery using the colorbox plugin (http://www.jacklmoore.com/colorbox/), and I somehow cannot get it to work.

I copied the demo code right off the webpage (I modified it to fit my links)

<!doctype html>

<html>

<head>

<link rel="stylesheet" href="colorbox.css" />

<script src="jquery.js"></script>

<script src="jquery.colorbox.min.js"></script>

</head>

<body>

<a class='gallery' href='image.jpg'>Photo_1</a>

<script>

alert('colorbox is about to open')

$("a.gallery").colorbox();

</script>

</body>

</html>


So, clearly i am doing something wrong, I just cannot figure out what. I included the jquery, colorbox and colorbox.css files in my directory with the html. If you can help me, thanks in advance!

Answer

You should get used to using either Firebug (a plugin for Firefox) and/or Google Chrome's inspector (which is there by default on Chrome). If you're using any of those, you can right click->inspect element, and then hit the 'Network' tab.

Refresh your page while you're in the Network tab, you'll see the HTTP requests. This will help you figure out if there is a mistyped path, or any unreachable files. Additionally, you will be able to see any javascript errors when you click the 'console' button. The console button is at the bottom left, it looks a bit like this: >=