I have a series of photos on a page, which have below them some text information and some buttons:
<div class="photowrapper">
<div class="photowrapperphoto">
<div class="photocontainer">image</div>
</div>
<div class="textwrapperphoto">
<div class="textleftwrapperphoto">
<div class="phototitle">photo_0001</div>
<div class="photoprice">£3.00</div>
<div class="photosize">6 by 4 inch</div>
</div>
<div class="textrightwrapperphoto">
<div class="photoaddbutton">Add</div>
<div class="photoremovebutton">Delete</div>
</div>
</div>
I want to put in some jquery so that when someone clicks on the 'photoaddbutton', it amends the class of 'photowrapperphoto' (to add a background color).
I can't seem to figure out how to identify the element photowrapperphoto.
I have loads of the above html (i.e. loads of images) on the page. I just want the immediately preceeding 'photowrapperphoto' to change, but at the moment the jquery I'm using changes all 'photowrapperphoto' classes on the page.
$(document).ready(function() {
$('.photoaddbutton').click(function() {
$('.photowrapperphoto').attr('class', 'photowrapperphotoselected');
});
});
Any ideas?