Copy Div and into another DIV
Hi,
I'm struggling to get the correct code for this.
I have a page with images and text. The image and text have their own Div's which have a class of either portimage or porttext
I want to be able to click on an image and for the text of the following porttext div to be displayed in another div called pinfo.
This is the code I have so far.
The jquery...
- $(document).ready(function(){
$('.porttext').hide();
$('.portsite').click ( function () {
var str = $(this).next('.porttext').text();
$('#pinfo').html(str);
});
});
...and the html...
- <div class="portsite">
<div class="portimage"><img src="images/peakfein.png" alt="Peak Fein" width="150"/></div>
<div class="porttext">Curabitur facilisis nisl eu nisi egestas nec auctor est blandit. Mauris pellentesque elit urna.</div>
</div>
<div class="portsite">
<div class="portimage"><img src="images/connectcentre.png" alt="Peak Fein" width="150" /></div>
<div class="porttext">Curabitur pulvinar dapibus orci at iaculis.</div>
</div>
<div class="secondary">
<div id="pinfo"></div>
</div>
Hope someone can help, getting a little confused :)
Thanks
James