I have the following code:
var lastMessage = $('.message:last');
.message is a div, I could use .html() to get the valueo f it, but I want the WHOLE div.
Example:
<div class="message">Content Here</div>
I don’t want the ‘Content Here’, I want '<div class="message">Content Here</div>'.
How can I do this?
Thanks
Try this:
It’s a little convoluted, but it is creating a new
div, cloning the full.message:lastdiv within that, then returning the HTML of the new div, which now includes your original.messageelement.Example fiddle