JS一些应用脚本

脚本一:

 //重置下标(可以修改成自己所需要的脚本)
    function ReSetBoxOrder() {
        var q = 0;//下标值
        var a = 0;//暂未用到
        //循环当前tbody下的所有tr
        $("#DetailTbody").find("tr").each(function () {
        //循环tr中的td
            $(this).find("td").each(function () {
                //循环td中的input
                $(this).find("input").each(function () {
                    var tdorder = $(this).attr("orderby");
                    //获取修改之前的name
                    var oldnames = $(this).attr("name");
                    //拼接一个新的name
                    var newtdnames = oldnames.substring(0, oldnames.indexOf("[") + 1) + q + oldnames.substring(oldnames.indexOf("]"));
                    //重新指定name
                    $(this).attr("name", newtdnames);
                    if (tdorder == "mp2") {
                        $(this).val(q + 1);
                    }
                    a++;
                });
            });
            q++;
            a = 0;
        });
    }

脚本二:

//实现51job的行业选择功能,样式和页面数据用的都是51的,只有脚本是自己写的。职能选择相差不大,可自行修改
 <script type="text/javascript">
        //点击确认关闭
        $(function () {
            $("body div span").click(function () {
                $("body div").hide();
            });
        });

        var num = 0;
        function tdClick(obj){
            var tdID = $(obj).children().attr("id");//获取点击位置td的ID,用以作为已选行业的class
            if ($(obj).find("input[type='checkbox']").prop("checked")) {
                $(obj).find("input[type='checkbox']").removeAttr("checked");
                //删除已选行业
                num = num-1;
                $("#selectNu").find("."+tdID+"").remove("."+tdID+"");
            } else {
                num = num+1;
                if(num <= 5){
                    $(obj).find("input[type='checkbox']").attr("checked", "checked");
                    //添加已选行业
                    $("#tdSelect").append("<span style='230px;display:inline-block;cursor: pointer;' class='"+tdID+"' onclick='selectChkNon(this)'><input type='checkbox' checked='checked' name='' onclick='selectChkNon(this)' />" + $(obj).text()) + "</span>";
                }else{
                      num = 5;
                     alert("最多选择五项!");
                }
            }
        }

        function chkClick(obj,event){
            var tdID = $(obj).attr("id");//获取点击chk的td的ID,用以作为已选行业的class
            var flag = $(obj).prop("checked");
            if (!flag) {
                $(obj).removeAttr("checked");
                //删除已选行业
                num = num - 1;
                $("#selectNu").find("."+tdID+"").remove("."+tdID+"");
            } else {
                num = num + 1;
                if(num <= 5){
                    $(obj).attr("checked", "checked");
                    //添加已选行业
                    $("#tdSelect").append("<span style='230px;display:inline-block;cursor: pointer;' class='"+tdID+"' onclick='selectChkNon(this)'><input type='checkbox' checked='checked' name='' onclick='selectChkNon(this)' />" + $(obj).parent().text()) + "</span>";
                }else{
                      num = 5;
                     $(obj).removeAttr("checked");
                     alert("最多选择五项!");
                }
            }
            event.stopPropagation();//防止事件冒泡
        }
        
        //点击已选行业取消
        function selectChkNon(obj){
            num = num - 1;
            var spanClass = $(obj).attr("class");//获取点击的class,class为行业的ID
            $("#selectNu").find("."+spanClass+"").remove("."+spanClass+"");
            $(".bgGray").find("#"+spanClass+"").removeAttr("checked");
        }

    </script>

<div class="jobLayer" style="border: 0px; background-color: rgb(255, 255, 255); z-index: 1111;
        position: absolute; visibility: visible; display: block; top: 69px; left: 235px;">
        <table border="0" cellpadding="0" cellspacing="0" style="font-size: 12px; ">
            <tr class="title" style="cursor: move;">
                <td colspan="4">
                    <img alt="" src="http://img01.51jobcdn.com/im/2009/search/title_layer_yd.gif" /><span>&nbsp;请选择行业类别(您最多能选择5项)</span>
                    <span class="ccType"><span cctype="confirm" style="cursor: pointer;">[确认]</span><span></span></span>
                </td>
            </tr>
            <tbody>
                <tr id="selectNu">
                    <td class="bigOrange" rowspan="1">
                        已选行业:
                    </td>
                    <td colspan='3' id="tdSelect" style="700px;"></td>
                </tr>
                <tr>
                    <td colspan="4" class="jlSeprator">
                    </td>
                </tr>
                <tr class="bgGray">
                    <td rowspan="3" class="bigOrange">
                        计算机/互联网/通信/电子:
                    </td>
                    <td class="zz_51Lower bgGray" style="cursor: pointer; padding-right: 15px;" onclick="tdClick(this)">
                        <input type="checkbox" name="" id="comSoftware" onclick="chkClick(this,event)"/>计算机软件
                    </td>
                    <td class="zz_51Lower bgGray" style="cursor: pointer; padding-right: 15px;" onclick="tdClick(this)">
                        <input type="checkbox" name="" id="comYing" onclick="chkClick(this,event)" />计算机硬件
                    </td>
                    <td class="zz_51Lower bgGray" style="cursor: pointer; padding-right: 15px;" onclick="tdClick(this)">
                        <input type="checkbox" name="" id="comService" onclick="chkClick(this,event)" />计算机服务(系统、数据服务、维修)
                    </td>
                </tr>
                <tr class="bgGray">
                    <td class="zz_51Lower bgGray" style="cursor: pointer; padding-right: 15px;" onclick="tdClick(this)" >
                        <input type="checkbox" name="" id="tongxin" onclick="chkClick(this,event)" />通信/电信/网络设备
                    </td>
                    <td class="zz_51Lower bgGray" style="cursor: pointer; padding-right: 15px;" onclick="tdClick(this)">
                        <input type="checkbox" name="" id="zengzhi" onclick="chkClick(this,event)" />通信/电信运营、增值服务
                    </td>
                    <td class="zz_51Lower bgGray" style="cursor: pointer; padding-right: 15px;" onclick="tdClick(this)">
                        <input type="checkbox" name="" id="comShop" onclick="chkClick(this,event)" />互联网/电子商务
                    </td>
                </tr>
</tbody>
</table>
</div>
原文地址:https://www.cnblogs.com/bobo-pcb/p/3957451.html