如何在jQuery中执行此操作?

Rak*_*yal 0 html jquery

我正在使用Stupid Fixed Header来修复两个表的标题.为此,我使用以下脚本.

$(document).ready(function(){       
    $("#table1").fixedHeader({
        height: 160,
        adjustWidth: function(th){
        if($.browser.msie){
            return $(th).width()+10;
        }
            return $(th).width();
        }
    });

    $("#table2").fixedHeader({
        height: 160,
        adjustWidth: function(th){
        if($.browser.msie){
            return $(th).width()+10;
        }
            return $(th).width();
        }
    });
})
Run Code Online (Sandbox Code Playgroud)

现在重点是,我正在写两次相同的代码.一次为table1,然后为table2.是否可以只写一次?

Dar*_*rov 5

$("#table1, #table2").fixedHeader ...
Run Code Online (Sandbox Code Playgroud)