解决方案 »

  1.   

                $(document).ready(function () {
                    //表格控制溢出滚动条出现首尾浮动
                    var h = $(".oa_xhlist").offset().top//得到容器的top位置
                    , l = 0
                    , ie7 = $.browser.msie && parseInt($.browser.version, 10) < 8//是否ie7-
                    , addh = 0; //用来保存点击展开搜索后和未展开搜索的高度差
                    var orginalH = h;//存储原始top位置
                    $(".oa_xhlist table tr").each(function () {
                        var firONE = $(this).children("td:first-child");
                        firONE.addClass("guding");
                        firONE.find(".guding").css({ "background-color": "#E4EBF4" });
                        $(this).find(".title").css({ "background-color": "#CCC", "height": "28px", "padding-top": "8px" });
                        $(this).find(".guding").next("td").addClass("xh");                    var lasttd = $(this).children("td:last-child");
                        lasttd.addClass("lastguding");
                        lasttd.prev().addClass("lastprevtd");
                        if (lasttd.text() == "操作") {
                            lasttd.addClass("hks");
                        } else {
                            lasttd.addClass("caozuoxing");
                        }                    if (ie7) {//IE8+支持不用设置top
                            //var offsetTop = $(".oa_xhlist").offset().top;
                            //$(".oa_xhlist").css({ "position": "relative" });//不用设置容器的相对定位,要不会随滚动条滚动了,要相对于body定位
                            firONE.add(lasttd).css({ "position": "absolute", "top": h });
                            h += $(this).outerHeight(true);
                            firONE.css({ "left": l });
                            l += $(this).scrollLeft();
                        }
                    })                function UpdateTRTop(h) { //用于IE7-展开/收缩收缩条件时更新那2列用
                        var top;
                        $(".oa_xhlist table tr").each(function () {
                            top = parseInt($(this).find('td:first').css('top'), 10) + h;
                            $(this).find('td:first').css('top', top).end().find("td:last-child").css('top', top)
                        });
                    }
                    $(".H_search_show_all").live("click", function () {
                        $(this).attr('src', 'http://www.huangkesong.cn/tablegd/search_up.png');
                        $(this).parent().animate({ "top": 44 + "px" }, 300);
                        $(this).closest(".H_search").animate({ 'height': 61 + 'px' }, 300, function () {
                            if (ie7) {
                                //得到高度差
                                if (addh == 0) addh = $(".oa_xhlist").offset().top - orginalH;                             UpdateTRTop(addh);
                            }
                        });
                        $(this).closest(".H_search").find(".btn_a").animate({ 'top': 44 + 'px' }, 300);
                        $(this).removeClass("H_search_show_all").addClass("H_search_show_yb");
                    })                $(".H_search_show_yb").live("click", function () {
                        $(this).attr('src', 'http://www.huangkesong.cn/tablegd/search_down.png');
                        $(this).parent().animate({ "top": 10 + "px" }, 300);
                        $(this).closest(".H_search").animate({ 'height': 26 + 'px' }, 300, function () {
                            if (ie7) UpdateTRTop(-addh);
                        });
                        $(this).closest(".H_search").find(".btn_a").animate({ 'top': 10 + 'px' }, 300);
                        $(this).removeClass("H_search_show_yb").addClass("H_search_show_all");
                    })                $("#H_hove_search").bind("mouseover", function () {
                        $(this).closest(".H_search").next().find(".H_nav_search").show();
                    }).bind("mouseleave", function () {
                        $(".H_nav_search").hide();
                    })                $(".H_nav_search").bind("mouseover", function () {
                        $(this).show();
                    }).bind("mouseleave", function () {
                        $(".H_nav_search").hide();
                    })                $("#dropdown p").click(function () {
                        var ul = $("#dropdown ul");
                        if (ul.css("display") == "none") {
                            ul.slideDown("fast");
                        } else {
                            ul.slideUp("fast");
                        }
                    });
                    $("#dropdown ul li a").click(function () {
                        var txt = $(this).text();
                        $("#dropdown p").html(txt);
                        var value = $(this).attr("rel");
                        $("#dropdown ul").hide();
                        //$("#result").html("您选择了"+txt+",值为:"+value);
                        $("#result").val(value);
                    });
                })更新行的位置会跳动,你要不想跳动,展开/收缩 搜索不要使用动画效果
      

  2.   


                    $(".H_search_show_all").live("click", function () {
                        $(this).attr('src', 'http://www.huangkesong.cn/tablegd/search_up.png');
    /////////////////
                        $(this).parent().css({ "top": 44 + "px" });
                        $(this).closest(".H_search").css({ 'height': 61 + 'px' });
                        if (ie7) {
                            //得到高度差
                            if (addh == 0) addh = $(".oa_xhlist").offset().top - orginalH;                        UpdateTRTop(addh);
                        }
    /////////////////
                        $(this).closest(".H_search").find(".btn_a").animate({ 'top': 44 + 'px' }, 300);
                        $(this).removeClass("H_search_show_all").addClass("H_search_show_yb");
                    })                $(".H_search_show_yb").live("click", function () {
                        $(this).attr('src', 'http://www.huangkesong.cn/tablegd/search_down.png');
    /////////////////
                        $(this).parent().css({ "top": 10 + "px" });
                        $(this).closest(".H_search").css({ 'height': 26 + 'px' });
                        if (ie7) UpdateTRTop(-addh);/////////////////
                        $(this).closest(".H_search").find(".btn_a").animate({ 'top': 10 + 'px' }, 300);
                        $(this).removeClass("H_search_show_yb").addClass("H_search_show_all");
                    });
      

  3.   


    为什么我挪到JS里面后却有错误提示那 而且还引发了我其他JS失效  为什么那  高手在给查询一下吧 !
      

  4.   

    放到$(document).ready(function () {这个里面替换原来的代码
      

  5.   


    还有 这个问题 就是和别的JS方法冲突 必须要放在  var h = $(".oa_xhlist").offset().top这句话的 上面才会执行 不然 其它JS就会失效?  
      

  6.   


    一连串的问题出现了,  这个是获取的一个class类,为什么就会没有找到了 但是我能alert()出东西来呀
      

  7.   


    非常的感谢你细心的回答 
    我不想让表格的行位置跳动我想让那两排是 动画形式    让筛选 不使用动画了 应该怎么修改下代码?2#你不是弄好了?检查你后续增加的代码是不是干扰到了吧。#3我只是去掉了动画效果animate而已
      

  8.   


     var h = $(".oa_xhlist").offset().top//得到容器的top位置网站上面 一直是报这个错误你能不能在线上帮忙看下?