Reputation: 1
I'm trying to get this lightbox script to work on a client site but I get this error '$ is not defined', I'm not well with JS so i was wondering if i could get some help, here's the site - http://www.petconnection.com/blog/.
Upvotes: 0
Views: 153
Reputation: 49188
In your HEAD tag, you need to do it in this order:
<head>
// other stuff
<script type="text/javascript" src="/res/javascript/jquery.js"></script>
<script type="text/javascript" src="/res/javascript/jquery.lightbox-0.5.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.storycontent a.lightbox').lightBox();
});
</script>
// other stuff
</head>
Use $(document).ready() instead of just calling the function, that way it waits until the full DOM is ready before it runs the lightBox method, and you don't have to put it all the way at the bottom of the page.
When I tried this just now, it worked just fine.
Upvotes: 0
Reputation: 10071
$ is the name of jQuery's main function. You're including your lightbox script before jQuery; jQuery has to come first.
Upvotes: 1