Click here to Skip to main content
15,880,543 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello Friends,

I am working with HTML,javascript and jquery in my code, dynamically add and delete the new elements to the existing "div".

Adding new element is working fine, but when I click on delete to remove the element, I get the Main Container object and also the child element object within the button exists and was clicked.

now the problem comes when I try to delete the element, I am getting the object till the html table control that contains the controls, but do not get the div that is containing the table.

Note : the div contains the table is the child div/element.

To Add element.
var ab = '<table rules="none" width="100%">
<td class="optHdBg">
<a><img src="themes/theme_blog/images/icons/delete.png" name="delete"  önclick="javascript:remove_block(this);"/></a>

function add()
var lstChild = $("#contControls").children().last();
var containerElement = document.getElementById("contControls");	
var newElement = document.createElement("div");

function remove_block(obj)
  var mainContainer = $(obj).parents("div #contControls");
  var mySelf = obj.parentNode.parentNode.parentNode.parentNode.parentNode;

problem occurs with mySelf control that is not accessing the div control that contains the table, due to that delete operation doesn't work.

please guide me.
Zoltán Zörgő 4-Sep-12 5:50am    
You are mixing JQuery with plain Javascript. JQuery has all that you need. Consult it's documentation first.

1 solution

See this for append and add functionality in JQuery:[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900