zoukankan      html  css  js  c++  java
  • 下拉框,带checkbox,多选

    看到很多都需要一个下拉的select ,集成多选的功能,就自己写了一个简陋的demo,in peace .有时间修改会再发新的版本

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script src="jquery-1.8.2.js" type="text/javascript"></script>
        <link href="style/select.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript">
            $(function () {
                $(".select_top_02").click(function () {
                    var mark = $(this).attr("mark");
                    if (mark == "off") {
                        $(".select_down").show();
                        $(this).attr("mark", "on");
                        $(this).addClass("select_top_02_on");
                    } else if (mark == "on") {
                        $(".select_down").hide();
                        $(this).attr("mark", "off");
                        $(this).removeClass("select_top_02_on");
                    }
    
                });
                $("#tj").click(function () {
                    var newArray = new Array();
                    $("input[name=dd]").each(function () {
                        if ($(this).prop("checked") == true) {
                            var text = $(this).val();
                            newArray.push(text);
                        }
                    });
                    var newText = newArray.join(',');
                    $("#select_input").val(newText);
                    $(".select_down").hide();
                    $(".select_top_02").removeClass("select_top_02_on");
                });
            });
        </script>
        <style type="text/css">
        
        </style>
    </head>
    <body>
    <div class="select_div">
        <div class="select_top">
            <div class="select_top_01">
                <input type="text" id="select_input"/>
            </div>
            <div class="select_top_02" mark="off">
                
            </div>
        </div>
        <div class="select_down">
            <div class="select_checkbox"><input type="checkbox" name="dd" value="1"/>1</div>
            <div class="select_checkbox"><input type="checkbox" name="dd" value="2"/>2</div>
            <div class="select_checkbox"><input type="checkbox" name="dd" value="3"/>3</div>
            <div class="select_checkbox"><input type="checkbox" name="dd" value="4"/>4</div>
            <div class="select_checkbox"><input type="checkbox" name="dd" value="5"/>5</div>
            <div class="select_checkbox"><input type="button" id="tj" value="确定"/></div>
        </div>
    </div>
    
    </body>
    </html>


    css页面:

    .select_div
    {
        width:200px;
        height:30px;
        position:relative;
        border:1px solid #f58805;
    }
    .select_top
    {
        width:198px;
        height:30px;
    }
    #select_input
    {
        width:198px;
        height:28px;
        border:0px;
    }
    .select_down
    {
        width:200px;
        height:auto;
        position:absolute;
        top:30px;
        left:0px;
        display:none;
    }
    .select_checkbox
    {
        width:200px;
        height:30px;
        line-height:30px;
    }
    .select_top_01
    {
        width:178px;
        height:28px;
        float:left;
    }
    .select_top_02
    {
        width:20px;
        height:28px;
        float:left;
        cursor:pointer;
        background:url(../images/arrow.png) center center no-repeat;
    }
    .select_top_02_on
    {
        background:url(../images/arrow_on.png) center center no-repeat;
    }
  • 相关阅读:
    QFramework 使用指南 2020(二):下载与版本介绍
    QFramework 使用指南 2020 (一): 概述
    Unity 游戏框架搭建 2018 (二) 单例的模板与最佳实践
    Unity 游戏框架搭建 2018 (一) 架构、框架与 QFramework 简介
    Unity 游戏框架搭建 2017 (二十三) 重构小工具 Platform
    Unity 游戏框架搭建 2017 (二十二) 简易引用计数器
    Unity 游戏框架搭建 2017 (二十一) 使用对象池时的一些细节
    你确定你会写 Dockerfile 吗?
    小白学 Python 爬虫(8):网页基础
    老司机大型车祸现场
  • 原文地址:https://www.cnblogs.com/lihaozhou/p/3494403.html
Copyright © 2011-2022 走看看