Search code examples
jqueryinternet-explorermootools

IE: Object doesn't support property or method 'closest'


I am getting "Object doesn't support property or method 'closest'" error in IE. I am using MooTools. Can anyone help me..

var li = $$('.list')[0].clone(true, true);

var NewContainer = li.getElement('div.tile');

NewContainer.removeProperty('style');

NewContainer.set('id', 'container_'+catId);

NewContainer.closest('li').set('id', 'list_'+countID);

Solution

  • MooTools doesn't have closest. You may have wanted getParent (which accepts a selector for finding an ancestor), but unlike jQuery's closest it doesn't look at the current element (I don't think that's an issue here).

    But note that you already have a reference to the li parent of NewContainer in the variable li.