I’m using the backstretch full page plugin found here: http://srobbin.com/jquery-plugins/backstretch/
Basically, I’m tasked with making a small gallery of 5 images – the code to change the background on click is
$("#outside").click(function(e) {
e.preventDefault();
$.backstretch('img/picture.jpg');
});
What I’m trying to do though is when you click an image, get the title attribute of that image and use it to define the filename backstretch is looking for
so:
<a class="clicker"><img src="/assets/img/image1.jpg" alt="image1" title="image1" /></a>
$(".clicker").click(function(e) {
e.preventDefault();
$.backstretch('img/pulledfromtitleattrib.jpg');
});
It might make more sense semantically to put new image filename on the rel attribute of the anchor, the title of the image should be related to that image.
If you would rather use your original markup the JS would be:
Either way uses jQuery’s .attr() method to grab attribute values.