* { margin:0px; padding:0px; box-sizing:border-box; } body { background:#59CDE9; /* fallback for old browsers */ background:-webkit-linear-gradient(to right,#0A2A88,#59CDE9); /* Chrome 10-25,Safari 5.1-6 */ background:linear-gradient(to right,#0A2A88,#59CDE9); /* W3C,IE 10+/ Edge,Firefox 16+,Chrome 26+,Opera 12+,Safari 7+ */ border-top:#59CDE9; } .List { position:relative; width:500px; margin-top:15px; cursor:pointer; left:50%; margin-left:-250px; /* transform:translateX(-50%); */ } .selectBox { position:relative; width:100%; height:30px; line-height:30px; padding:0px 5px; /* background-color:aquamarine; */ border:1px solid rgba(200,200,200,1); border-radius:3px; display:flex; flex-direction:row; justify-content:space-between; align-items:center; cursor:pointer; z-index:1; } .selectBox .selectContent { width:calc(100% - 20px); overflow:hidden; white-space:nowrap; color:white; /* background-color:blue; */ } .selectBox .clear { width:10px; color:gray; font-size:12px; } .selectBox .ico { width:0px; height:0px; border:7px solid transparent; border-top:5px solid black; margin-top:5px; margin-left:5px; } .itemBox { position:absolute; width:100%; height:300px; overflow-y:auto; background-color:rgb(255,255,255); display:flex; flex-direction:column; transition-duration:0.1s; z-index:190; cursor:pointer; /* border:1px solid gray; */ box-shadow:gray 0px 0px 5px; border-radius:5px; margin-top:3px; /* opacity:1; */ } .itemBox .lookup { position:sticky; top:0px; width:100%; height:30px; line-height:30px; background-color:rgb(255,255,255); display:inline-flex; flex-direction:row; flex-wrap:nowrap; align-items:center; /* overflow:hidden; */ border-bottom:1px solid rgba(222,222,222,1); } .List input[type=checkbox] { width:20px; background-color:white; } .itemBox .lookup input[type=text] { width:calc(100% - 25px); height:30px; line-height:100%; outline:none; border:none; /* background-color:aqua; */ border-bottom:1px solid rgba(222,222,222,1); } .itemBox .item { /* padding:5px 0px; */ height:30px; line-height:30px; cursor:pointer; } .itemBox .item:hover { background-image:linear-gradient(to right,rgba(0,0,0,0.3),rgba(255,255,255,0.3)); color:white; } .itemBox .item label { display:inline-block; width:calc(100% - 20px); height:100%; /* background-color:burlywood; */ cursor:pointer; } .itemClose { height:0px; /* opacity:0; */ /* display:none; */ transition-duration:0.1s; } input[value=取值] { padding:5px 20px; }
更新时间:2022-04-28 01:03:20
绑定方式:
var n=new list("div_id",对象数组);//对象数组
格式:
[{text:'现金',value:'1001',},{text:'银行存款',value:'1002',},……]
提供两个输出接口:gettext()和getvalue(),容易理解,分别得到已选择项的text或value集合,是用','分隔的字符串。
用法:
var a=n.gettext();