domino
domino

Reputation: 7345

Trying to combine jquery clone, appendTo

$('.reply').click(function () {

                var replybox = $(".replybox").clone().show();
                $(replybox).appendTo(this,parent('.post'));

        });

What I'm trying to do:

  1. Clone .replybox (display:none;) then make it visible
  2. Put inside $(this).parent('.post')
  3. Ideally make .replybox show/hide on .reply click (kinda like youtube comments reply box).

Upvotes: 0

Views: 342

Answers (3)

thecodeparadox
thecodeparadox

Reputation: 87073

$('.reply').click(function () {
    var replybox = $(".replybox:hidden"); // take a reference of replybox
    $(this).parent('.post').append(replybox.clone().show());
});

Upvotes: 1

Bram Vanroy
Bram Vanroy

Reputation: 28437

$(".reply").click(function () {
 $(this).parent(".replybox").clone().hide().appendTo($(this).parents(".post")).fadeIn("slow") 
});​

But I'm still not sure what you want or what your HTML structure is, so probably this isn't what you want.

Upvotes: 1

jcampbelly
jcampbelly

Reputation: 652

$('.reply').click(function () {
    $(this).parent('.post').append($(".replybox").clone().show());
});

Upvotes: 1

Related Questions