zoukankan      html  css  js  c++  java
  • 无题

        <script src="../js/jquery-1.4.2.min.js" type="text/javascript"></script>
        <script type="text/javascript">
            function showDiv(ids) {
                var dis = $("#" + ids).attr("dis");
                var div = $("#div" + dis);
                var towhere = $("#"+ids).attr("jj");
                if (div.is(":visible")) {
                    div.hide();
                }
                else {
                    div.show();
                }
                //bind events
                if (!div.data("hasbind")) {
                    div.find(":checkbox").click(function () {
                        var txt = $(this).next().text();
                        if (txt == "任意") {
                            div.find(":checkbox").slice(1).attr("checked", false);
                            div.find(":checkbox:first").attr("checked", true);
                            $("#" + towhere).val($(this).attr("checked") ? txt : "");
                            return;
                        }
                        else if (div.find(":checkbox:checked").length == div.find(":checkbox").length - 1) {
                            div.find(":checkbox").slice(1).attr("checked", false);
                            div.find(":checkbox:first").attr("checked", true);
                            $("#" + towhere).val("任意");
                            return;
                        }
                        else {
                            div.find(":checkbox:first").attr("checked", false);
                        }
                        var arr = [];
                        div.find(":checkbox:checked").each(function () {
                            arr.push($(this).next().text());
                        });
                        $("#" + towhere).val(arr.join(','));
                    });
                    div.data("hasbind", true);
                }
            }
            $(document).ready(function () {
                //            $("#marriage_con").click(function () {
                //                var dis = $(this).attr("dis");
                //                var div = $("#div" + dis);
                //                var towhere = $(this).attr("jj");
                //                if (div.is(":visible")) {
                //                    div.hide();
                //                }
                //                else {
                //                    div.show();
                //                }
                //                //bind events
                //                if (!div.data("hasbind")) {
                //                    div.find(":checkbox").click(function () {
                //                        var txt = $(this).next().text();
                //                        if (txt == "任意") {
                //                            div.find(":checkbox").slice(1).attr("checked", false);
                //                            $("#" + towhere).val($(this).attr("checked") ? txt : "");
                //                            return;
                //                        }
                //                        else if (div.find(":checkbox:checked").length == div.find(":checkbox").length - 1) {
                //                            div.find(":checkbox").slice(1).attr("checked", false);
                //                            div.find(":checkbox:first").attr("checked", true);
                //                            $("#" + towhere).val("任意");
                //                            return;
                //                        }
                //                        else {
                //                            div.find(":checkbox:first").attr("checked", false);
                //                        }

                //                        var arr = [];
                //                        div.find(":checkbox:checked").each(function () {
                //                            arr.push($(this).next().text());
                //                        });
                //                        $("#" + towhere).val(arr.join(','));
                //                    });
                //                    div.data("hasbind", true);
                //                }
                //            });
            });
          
        </script>

  • 相关阅读:
    Spring Boot面试题(转至)
    深入理解Java输入输出流
    java基础 第十六章(连接数据库)
    java基础 第十五章(数据库)
    java基础 第十四章(Servlet声明周期、Servlet向jsp中提供数据、Servlet跳转jsp、jsp中书写java代码)
    java基础 第十三章(HashMap、Servlet介绍)
    java基础 第十二章(异常处理、工具类、集合)
    java基础 第十一章(多态、抽象类、接口、包装类、String)
    java基础 第十章(this,继承,重写和重载的区别)
    java基础 第九章(设计模式 单例模式)
  • 原文地址:https://www.cnblogs.com/caishuowen/p/2121990.html
Copyright © 2011-2022 走看看