Jquery parent()不';他似乎不在工作

Jquery parent()不';他似乎不在工作,jquery,parent,Jquery,Parent,.parent()未返回我指定的父元素。我看不出我的代码或html有任何问题 Javascript: var vehicle = function () { return { init: function () { var that = this; jQuery('.vehicle-year-profile .options .delete').bind('click', function (e) {

.parent()未返回我指定的父元素。我看不出我的代码或html有任何问题

Javascript:

var vehicle = function () {
    return {
        init: function () {
            var that = this;

            jQuery('.vehicle-year-profile .options .delete').bind('click', function (e) {
                e.preventDefault();
                console.log(e.currentTarget); //  [a.close #]
                that.remove(jQuery(e.currentTarget).parent('.vehicle-year-profile'));
            });
        },
        remove: function (el) {
            console.log(el); // []
            jQuery(el).remove();
        }
    }
}();
jQuery(function() {
    vehicle.init();
});
HTML:

    <div id="vehicle-101031994" class="vehicle-year-profile">
                                        <div class="left">
                                            <h4>1994</h4>
                                        </div>
                                        <div class="right options">
                                            <a class="edit" href="#"><img class="icon-small" src="/image/icons/pencil.png"></a>
                                            <a class="delete" href="#"><img class="icon-small" src="/image/icons/delete.png"></a>
                                        </div>
                                        <div class="clear"></div>
</div>

1994

您引用的元素不是直接父元素

请尝试以下方法:

that.remove(jQuery(this).closest('.vehicle-year-profile'));
这是

.parents()和.parent()方法类似,不同的是后者只在DOM树上移动一个级别

您要查找的父级是两级,因此您必须使用
.parents()
(甚至更好)