I'd like the parent div ".card" of the button to be added to the blue div upon clicking the button, and also able to "returned" to the original red div upon clicking the button again. jsfiddle
<div id="nonSelected">
<div class="card">
CARD #1
<input id="btnDefault" onclick="moveButton(this)" type="button" class="btn btn-default" value="ADD" />
</div>
<div class="card">
CARD #2
<input id="btnDefault" onclick="moveButton(this)" type="button" class="btn btn-default" value="ADD" />
</div>
</div>
<div id="selected">
</div>
<script>
function moveButton(elem){
if( $(elem).parent().attr("id") == "nonSelected" ){
$(elem).detach().appendTo('#selected');
}
else{
$(elem).detach().appendTo('#nonSelected');
}
}
</script>