Swap Multiple Divs on Page without triggering the others.
Hi there -
I'm new to jQuery - but I'm really loving it so far - can't wait to dig in. Currently I'm using this code:
- $(document).ready(function(){
//when a link inside our thumbba div is clicked
$('#thumbb a').click(function(event){
//prevent the default behavior(going to the page)
event.preventDefault();
//get the href attribute of the link
var link = $(this).attr('href');
//replace the swap-a div with the new content
$('#swap-a').load(link+' #swap-b');
});
});
to swap out content from a hidden div (swap-b) into the visible div (swap-a) - this works great, however, I have 12 of these "hidden" divs on the page, and I want each one to behave independently. Currently, when I click the swap button for one div, it activates all the others. I get that this is because all the divs have the same IDs, and that the function is telling all the divs to behave the same, however, I don't see how I'm supposed to apply this function to each div independently. I've tried using a "this" function to make it work, however that just breaks the function. I'd love some insight.
Thanks!