javascriptjquerydomexception

What exactly can cause an "HIERARCHY_REQUEST_ERR: DOM Exception 3"-Error?


How exactly does it relate to jQuery? I know the library uses native javascript functions internally, but what exactly is it trying to do whenever such a problem appears?


Solution

  • It means you've tried to insert a DOM node into a place in the DOM tree where it cannot go. The most common place I see this is on Safari which doesn't allow the following:

    document.appendChild(document.createElement('div'));
    

    Generally, this is just a mistake where this was actually intended:

    document.body.appendChild(document.createElement('div'));
    

    Other causes seen in the wild (summarized from comments):