1

Okay, so originally, I had a program where when I clicked on the container, it added the entire container to an array, and then posted it in a sidebar.

Now I want it so when I click a button inside the div, it adds the entire container. Although I seem to have problems getting it working.

At the moment, it add the button to the array because I say .push($(this))

What would I use to add the entire individual div?

2 Answers 2

1

Clone the .parent() element.

favorites.push($(this).parent().clone());

http://jsfiddle.net/zPMNV/

Sign up to request clarification or add additional context in comments.

2 Comments

Is there any way I could remove the button, once it is pushed to the array and posted on the sidebar?
@Christopher Your first assumption was correct, I upvoted your answer. Let's delete our comments.
1

Clone the parent and then call remove on the clone

var clone = $(this).parent().clone();
$(clone.find("input")).remove();
favorites.push(clone);
$('.favorite').append(favorites);

http://jsfiddle.net/zPMNV/10/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.