In the Jquery example below, I would like to expand $(this) before it is cloned, so it includes everything contained in the parent class “comment”. How do I do this? I’ve tried using ReplaceWith($(this).parent(‘.comment’).clone()… and it does not work!
$(document).ready(
function(){
$('.forumthreadtitle').siblings().hide();
$('.forumthreadtitle').click( function() {
$('#first-post').replaceWith($(this).clone().attr('id','first-post'));
});
To get the closest
class="comment"parent and clone it, do this:.parent(selector)only finds if it’s the immediate parent. The equivalent for this (since comment isn’t the element itself) would be:.parents(".comment:first").