i'm having 2 buttons one to create a div and the other is to remove the added div. There's no problem adding a new div but when i try to remove it i can't use div:eq(index) because it wasn't loaded with the DOM here's the code
$(document).ready(function(e) {
$(".inner").eq(1).css("background-color","#0C9");
$(".inner").eq(2).css("background-color","#F00");
$(".inner").eq(3).css("background-color","#990");
$("#add").click(function(){
$(".content").append("<div class='inner'><a href='#' class='rem'>remove this inner</a></div>");
});
$(document).on("click","a.rem",function(e){
e.preventDefault();
var num = $("a.rem").index(this);
//alert(num);
$(".inner").eq(num).remove();
});
});
</script>
code on jsfiddle : http://jsfiddle.net/7uzSv/3/