javascript - jquery $(this).parents('.cssClassName') only finds window in IE, but works in other browsers -
i have following jquery code:
jquery(function ($) { $(document).on('click', '.del', function () { var self = $(this); parent = self.parents('.transportrow'); parent.remove(); }); });
when click link class "del" inside div class "transportrow" div should removed.
this working fine in webkit , firefox, not in ie
i error tells me object not support property or method "remove".
when inspect in debugger, parent seems window, not div element.
does know how script running in ie?
when use parent
without var
refer global variable parent
a.k.a. parent
property on global (window
) object.
in ie window.parent
property readonly (in reality property attribute [[writable]]
of property set false
or not set @ all).
changing row:
parent = self.parents('.transportrow');
to
var parent = self.parents('.transportrow');
should trick. or change names.
crockford talks issue , recommends using that
instead of self
. advice applicable on parent
say.
Comments
Post a Comment