So I have code like this:
$(".list").append('<li>hi</li>');
Here’s a working example: http://jsfiddle.net/pXaSC
When you click the + button, it adds a button to a ul.
If you copied and pasted the .buttons div (replicating the button and list) and clicked the + button on either of them, it would append a list item on both of them (http://jsfiddle.net/pXaSC/1/).
What I would like to achieve, however, is to make both lists work independently.
I know I need to use a (this) and .parent() selector somehow, but I just can’t figure it out. I do not want to use id‘s.
In the event handler for the button click,
thiscorresponds to the button. Therefore, you need to navigate a bit through the DOM tree to the desired<ul class="list">:One level up to the parent (the enclosing
<div>), then find the<ul>inside that div.http://jsfiddle.net/pXaSC/4/