How to remove an element that is added dynamically in javascript
问题 I have the following code to create some element <div id="parent"> <div id="block_1" > <div> <input type="text"> </div> <img src="arrow.jpg"> <div> <input type="text"> </div> <div><a href="#" class="remove_block">Remove</a></div> </div> </div> the result look like this When user presses the ADD button it will go to a javascript function and create the same block of div. Here is the code function add_block() { var curDiv = $('#parent'); var i = $('#parent div').size()/4 + 1; var newDiv='<div