jQuery&;$。fn在IE7中未定义 $(窗口).load(函数(){ 警报(类型为$.fn.init_deps); }); $(文档).ready(函数(){ /*部门交换机*/ $.fn.init_deps=函数{ 变量o={ deps:错,, 猫:错 } $扩展(o,s); 如果(!s.deps | |!s.cats){return;} 返回此值。每个(函数(){ 变量选择=$(“”) .附于(本) .部门 .change(函数(){ var select=$('select#category'); select.categories({cats:s.cats,current_dep:$(this.val()}); var p_width=select.parent().outerWidth(); var ch_width=select.outerWidth(); select.parent().css('width',p_width+'px')) .find('select').css('width',(Chu宽度+8)+'px')) .parent().find('span').css('width',(p_width-20)+'px'); $.uniform.update(选择); }); var p_width=select.parent().outerWidth(); var ch_width=select.outerWidth(); select.uniform({selectClass:'selector uni1'}) .parent().css('width',p_width+'px') .find('select').css('width',(Chu宽度+8)+'px')) .parent().find('span').css('width',(p_width-20)+'px'); }); } });

jQuery&;$。fn在IE7中未定义 $(窗口).load(函数(){ 警报(类型为$.fn.init_deps); }); $(文档).ready(函数(){ /*部门交换机*/ $.fn.init_deps=函数{ 变量o={ deps:错,, 猫:错 } $扩展(o,s); 如果(!s.deps | |!s.cats){return;} 返回此值。每个(函数(){ 变量选择=$(“”) .附于(本) .部门 .change(函数(){ var select=$('select#category'); select.categories({cats:s.cats,current_dep:$(this.val()}); var p_width=select.parent().outerWidth(); var ch_width=select.outerWidth(); select.parent().css('width',p_width+'px')) .find('select').css('width',(Chu宽度+8)+'px')) .parent().find('span').css('width',(p_width-20)+'px'); $.uniform.update(选择); }); var p_width=select.parent().outerWidth(); var ch_width=select.outerWidth(); select.uniform({selectClass:'selector uni1'}) .parent().css('width',p_width+'px') .find('select').css('width',(Chu宽度+8)+'px')) .parent().find('span').css('width',(p_width-20)+'px'); }); } });,jquery,internet-explorer-7,Jquery,Internet Explorer 7,Alert在IE7中返回未定义,但在所有其他浏览器中返回函数 帮助,无法找出问题所在。在IE中绑定函数之前可能会触发window onload。您应该在文档准备就绪之前定义$.fn $(window).load(function(){ alert(typeof $.fn.init_deps); }); $(document).ready(function(){ /* Departments switcher */ $.fn.init_deps = function(s){

Alert在IE7中返回未定义,但在所有其他浏览器中返回函数


帮助,无法找出问题所在。

在IE中绑定函数之前可能会触发window onload。您应该在文档准备就绪之前定义$.fn

$(window).load(function(){

alert(typeof $.fn.init_deps);

});

$(document).ready(function(){

    /* Departments switcher */
    $.fn.init_deps = function(s){

        var o = {
            deps:false,
            cats:false              
        }
        $.extend(o,s);

        if(!s.deps || !s.cats) {return;}
        return this.each(function(){

            var select = $('<select id="department" name="department"></select>')
                .appendTo(this)
                .departments(s)
                .change(function(){
                    var select = $('select#category');
                    select.categories({cats:s.cats,current_dep:$(this).val()});

                    var p_width = select.parent().outerWidth();
                    var ch_width = select.outerWidth();
                    select.parent().css('width',p_width+'px')
                        .find('select').css('width',(ch_width + 8)+'px')
                        .parent().find('span').css('width',(p_width - 20)+'px');    
                    $.uniform.update(select);
                });

            var p_width = select.parent().outerWidth();
            var ch_width = select.outerWidth();
            select.uniform({selectClass:'selector uni1'})
                .parent().css('width',p_width+'px')
                .find('select').css('width',(ch_width + 8)+'px')
                .parent().find('span').css('width',(p_width - 20)+'px');            

        });

    }
});
$(窗口).load(函数(){
警报(类型为$.fn.init_deps);
});
(函数($){
$.fn.init_deps=函数{
变量o={
deps:错,,
猫:错
}
$扩展(o,s);
如果(!s.deps | |!s.cats){return;}
返回此值。每个(函数(){
变量选择=$(“”)
.附于(本)
.部门
.change(函数(){
var select=$('select#category');
select.categories({cats:s.cats,current_dep:$(this.val()});
var p_width=select.parent().outerWidth();
var ch_width=select.outerWidth();
select.parent().css('width',p_width+'px'))
.find('select').css('width',(Chu宽度+8)+'px'))
.parent().find('span').css('width',(p_width-20)+'px');
$.uniform.update(选择);
});
var p_width=select.parent().outerWidth();
var ch_width=select.outerWidth();
select.uniform({selectClass:'selector uni1'})
.parent().css('width',p_width+'px')
.find('select').css('width',(Chu宽度+8)+'px'))
.parent().find('span').css('width',(p_width-20)+'px');
});
}
})(jQuery);

窗口onload可能在IE中绑定函数之前触发。您应该在
文档准备就绪之前定义$.fn

$(window).load(function(){

alert(typeof $.fn.init_deps);

});

$(document).ready(function(){

    /* Departments switcher */
    $.fn.init_deps = function(s){

        var o = {
            deps:false,
            cats:false              
        }
        $.extend(o,s);

        if(!s.deps || !s.cats) {return;}
        return this.each(function(){

            var select = $('<select id="department" name="department"></select>')
                .appendTo(this)
                .departments(s)
                .change(function(){
                    var select = $('select#category');
                    select.categories({cats:s.cats,current_dep:$(this).val()});

                    var p_width = select.parent().outerWidth();
                    var ch_width = select.outerWidth();
                    select.parent().css('width',p_width+'px')
                        .find('select').css('width',(ch_width + 8)+'px')
                        .parent().find('span').css('width',(p_width - 20)+'px');    
                    $.uniform.update(select);
                });

            var p_width = select.parent().outerWidth();
            var ch_width = select.outerWidth();
            select.uniform({selectClass:'selector uni1'})
                .parent().css('width',p_width+'px')
                .find('select').css('width',(ch_width + 8)+'px')
                .parent().find('span').css('width',(p_width - 20)+'px');            

        });

    }
});
$(窗口).load(函数(){
警报(类型为$.fn.init_deps);
});
(函数($){
$.fn.init_deps=函数{
变量o={
deps:错,,
猫:错
}
$扩展(o,s);
如果(!s.deps | |!s.cats){return;}
返回此值。每个(函数(){
变量选择=$(“”)
.附于(本)
.部门
.change(函数(){
var select=$('select#category');
select.categories({cats:s.cats,current_dep:$(this.val()});
var p_width=select.parent().outerWidth();
var ch_width=select.outerWidth();
select.parent().css('width',p_width+'px'))
.find('select').css('width',(Chu宽度+8)+'px'))
.parent().find('span').css('width',(p_width-20)+'px');
$.uniform.update(选择);
});
var p_width=select.parent().outerWidth();
var ch_width=select.outerWidth();
select.uniform({selectClass:'selector uni1'})
.parent().css('width',p_width+'px')
.find('select').css('width',(Chu宽度+8)+'px'))
.parent().find('span').css('width',(p_width-20)+'px');
});
}
})(jQuery);

$document.ready在不同浏览器中的工作方式不同。在IE中,它将绑定到windows onload

$(window).load(function(){

alert(typeof $.fn.init_deps);

});
(function($){

    $.fn.init_deps = function(s){

        var o = {
            deps:false,
            cats:false              
        }
        $.extend(o,s);

        if(!s.deps || !s.cats) {return;}
        return this.each(function(){

            var select = $('<select id="department" name="department"></select>')
                .appendTo(this)
                .departments(s)
                .change(function(){
                    var select = $('select#category');
                    select.categories({cats:s.cats,current_dep:$(this).val()});

                    var p_width = select.parent().outerWidth();
                    var ch_width = select.outerWidth();
                    select.parent().css('width',p_width+'px')
                        .find('select').css('width',(ch_width + 8)+'px')
                        .parent().find('span').css('width',(p_width - 20)+'px');    
                    $.uniform.update(select);
                });

            var p_width = select.parent().outerWidth();
            var ch_width = select.outerWidth();
            select.uniform({selectClass:'selector uni1'})
                .parent().css('width',p_width+'px')
                .find('select').css('width',(ch_width + 8)+'px')
                .parent().find('span').css('width',(p_width - 20)+'px');            

        });

    }
})(jQuery);

因此,您不能指望document.ready块中的代码在onload块之前运行。

$document.ready在不同浏览器中的工作方式不同。在IE中,它将绑定到windows onload

$(window).load(function(){

alert(typeof $.fn.init_deps);

});
(function($){

    $.fn.init_deps = function(s){

        var o = {
            deps:false,
            cats:false              
        }
        $.extend(o,s);

        if(!s.deps || !s.cats) {return;}
        return this.each(function(){

            var select = $('<select id="department" name="department"></select>')
                .appendTo(this)
                .departments(s)
                .change(function(){
                    var select = $('select#category');
                    select.categories({cats:s.cats,current_dep:$(this).val()});

                    var p_width = select.parent().outerWidth();
                    var ch_width = select.outerWidth();
                    select.parent().css('width',p_width+'px')
                        .find('select').css('width',(ch_width + 8)+'px')
                        .parent().find('span').css('width',(p_width - 20)+'px');    
                    $.uniform.update(select);
                });

            var p_width = select.parent().outerWidth();
            var ch_width = select.outerWidth();
            select.uniform({selectClass:'selector uni1'})
                .parent().css('width',p_width+'px')
                .find('select').css('width',(ch_width + 8)+'px')
                .parent().find('span').css('width',(p_width - 20)+'px');            

        });

    }
})(jQuery);

因此,您不能指望document.ready块中的代码在onload块之前运行。

IE根本不会抛出警报,也不会抛出错误。我完全糊涂了。但如果我完全删除函数,我会发出警报。这意味着有一个脚本错误。尝试注释代码的某些部分,例如数学上指定宽度/高度的部分,并查看其格式是否正确。另外,请确保您没有使用IE保留字,尝试为某些变量指定不同的名称。确保在DOM就绪之前,通过将其放入
(函数($){
函数中,确保
$.fn.departments
$.fn.categories
也被分配到DOM就绪之前。该死,我已经找到了它停止的位置。var o={deps:false,}进一步了解代码。但为什么IE没有抛出错误?对不起,各位。IE根本没有抛出警报,也没有抛出错误。我完全困惑。但如果我完全删除函数,我确实会抛出警报。这意味着存在脚本错误。试着注释代码的部分,比如数学上指定宽度/高度和宽度的部分看看是不是