So i have several divs that are hidden and when a user clicks an image it will load the content from that div. I have a working method but believe it's not the correct method.
The HTML
<div class="slide">
<img src="images/image1.jpg" alt="" id="project-1" />
<img src="images/image2.jpg" alt="" id="project-2" />
<img src="images/image3.jpg" alt="" id="project-3" />
</div>
<div id="project-1" class="hidden">
<p>Project </p>
</div>
<div id="project-2" class="hidden">
<p>Project 2</p>
</div>
<div id="project-3" class="hidden">
<p>Project 3</p>
</div>
<div id="main">
</div>
Current jQuery:
$(document).ready(function()
{
$('.slide img').click(function ()
{
var project = $(this).attr('id');
$('#main').fadeOut('slow', function() {
$("#main").load(window.location.pathname+" #"+project+" > *").fadeIn('slow');
});
});
});
As you can see it's using load() to load data from the same page, is there a better function to use than load for this, i want to take all the data from one div and put it into the #main div. The project var stores the name of the div i want to get the data from.