When i use appendBox function below, first time it works fine and the same with removeBox, but second time it doesn't work properly: it duplicates my content.
What is wrong?
function appendBox( id )
{
$("#listContainer").append("<div id=\"appendbox-"+ id +"\"><a href=\"javascript:removeBox("+ id +");\">remove</a></div>");
$("#addBox-"+ id ).slideUp();
}
function removeBox( id )
{
$("#listMyBoxs").append("<div id=\"addBox-"+ id +"\"><a href=\"javascript:appendBox("+ id +");\">tilføj</a></div>");
$("#appendbox-"+ id ).slideUp();
}
this its my html when i try this test
<div style="height: 200px; border: 1px solid black;">
<div id="listContainer"></div>
<div id="listMyBoxs">
<div id="addBox-1">
<a href="javascript:appendBox( 1 );">tilføj</a>
</div>
</div>
</div>