0

Hi,

I want to remove the current DOM using tagName=DIV. Below function works fine in IE but not working properly in mozilla. The 'if' part is for IE and 'else' part is for mozilla FF. In 'else' part,The current DIV is not removing, only the DIV at position 1,that is the div at the first element in the array is removed.

Kindly anybody give me solution on how to remove the current childelement in mozilla.

function removeit(e)
{

if (window.event) 
{ 
var current = window.event.srcElement;
while ( (current = current.parentElement)  && current.tagName !="DIV");
 current.parentElement.removeChild(current);
}

else
{
var current = e.target;
var element = document.getElementById("moreUploads"); // its a div 
while (element.childNodes[0])  {   
 element.removeChild(element.childNodes[0]);
 removeChildNodes(element);  }
}

}

Edited by Nick Evan: Fixed formatting

2
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by Airshow
0

Pradeepktg,

Use parentNode rather than parentElement . This will work in both browsers without needing to branch.

Airshow

0

Pradeepktg,

Use parentNode rather than parentElement . This will work in both browsers without needing to branch.

Airshow

Airshow,

Thats for your effort. I made it work in other way,ofcourse using parentNode. The posted code was bit complicated. I made it easier n it all worked fine.
Thanks,

0

Pradeepktg,

If "solved" then could you please mark the topic as such.

Thanks
Airshow

Hi Airshow,

Sorry for not marking the thread as "solved". Since am a new user, i dont know how to mark this thread as solved. It would be better if you can assist me on this.
Thanks,

0

Pradeep,

That's a very good question. I have only ever answered questions here, not asked. Therefore never had occasion to mark solved.

It must be something available to you as original poster of a topic. I guess that when viewing the topic, there's a "Mark Solved" button/link somewhere toward top or bottom of the page. If you still can't find it then try asking a moderator (click "Currently online" at very top of page, then look for bold entry in the ""Who's Online list ....).

Another option is the "Daniweb Community Feedback" forum - you could ask there.

There must be some help pages somewhere in Daniweb but I've never found them!

Airshow

Edited by peter_budo: Corrected link

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.