Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Elizabeth Mawer
Elizabeth Mawer
9,554 Points

Where do I add the JavaScript function to create an Image Gallery?

Fire the plugin Bind the swipebox behaviour on every link with the "swipebox" class.

<script type="text/javascript"> ;( function( $ ) {

$( '.swipebox' ).swipebox();

} )( jQuery ); </script>

I have tried putting the code at the start and end of my HTML but this didn't work. Any help gratefully appreciated!!

2 Answers

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,252 Points

The best place is generally right before the closing body tag in your HTML document. Remember to include the source and type attribute in your script tag.

<script src = "script.js" type="text/javascript"></script>
Melissa Austin
Melissa Austin
3,383 Points

In HTML5, the type attribute is no longer required for JavaScript. The default value is "text/javascript".