<div class="menu">
     <div class="submenu"></div>
</div>(function() {
    var myjQuery = jQuery.sub();
    myjQuery.fn.remove = function() {
        this.trigger("remove");
        return jQuery.fn.remove.apply( this, arguments );
    };
    myjQuery(function($) {
        $(".menu").click(function() {
            $(this).find(".submenu").remove();
        });
        //这个绑定函数没触发,要怎么才能触发呢?
        $(document).bind("remove", function(e) {
            $(e.target).parent().hide();
        });
    });
})();
上面这个函数有点看不懂,多谢大家指教啦~jquery工具functionjavascript

解决方案 »

  1.   

    var myjQuery = jQuery.sub();
    API:可创建一个新的jQuery副本,不影响原有的jQuery对像。
    按api的说法相当于拷贝一份jQuery对象,也就是在这个对象是一个新对象,与jQuery/$没有关系myjQuery(document).bind("remove", function(e) {
                $(e.target).parent().hide();
    });
    这样就可以成功了
      

  2.   

    直接看api:
    http://www.css88.com/jqapi-1.7/#p=jQuery.sub
      

  3.   

    myjQuery(function($) {
            $(".menu").click(function() {
                $(this).find(".submenu").remove();
            });
            //这个绑定函数没触发,要怎么才能触发呢?
            $(document).bind("remove", function(e) {
                $(e.target).parent().hide();
            });
        });里面已经将$传进去了啊~在这里$就是代表myjQuery对象吧?
      

  4.   

    这个官方例子有点2B.//这个绑定函数没触发,要怎么才能触发呢?
            $(document).bind("remove", function(e) {
                $(e.target).parent().hide();
            });这个绑定函数就是不触发的,表示myjQuery做的更改不影响jQuery.myjQuery(function($) {
            $(".menu").click(function() {
                $(this).find(".submenu").remove();
            });
            //这个绑定函数没触发,要怎么才能触发呢?
            $(document).bind("remove", function(e) {
                $(e.target).parent().hide();
            });
        });
    里面已经将$传进去了啊~在这里$就是代表jQuery,而不是myjQuery