Search code examples
javascriptjqueryclonedeep-copyclonenode

IE8 cloneNode(true) object doesn't support this property or method


$('#attachment-deletion').cloneNode(true);

IE reports Object doesn't support this property or method

what can I do about this? cloneNode was my solution to IE8 not recognizing jquery's clone method, which it didn't even throw an error about


Solution

  • cloneNode is a native javascript method that doesn't work on jQuery objects, you have decide what to use :

    jQuery

    $('#attachment-deletion').clone(true);
    

    or plain JS

    document.getElementById('attachment-deletion').cloneNode(true);
    

    Edit: You can also Combine Plain JS with jQuery if you need to:

    $('#attachment-deletion').get(0).cloneNode(true);
    // or
    $('#attachment-deletion')[0].cloneNode(true);