div+css模拟select下拉框实例代码

  1. <span class="pun">无标题文档</span> .mod_select ul{margin:0;padding:0;} .mod_select ul:after{ display: block; clear: both; visibility: hidden; height: 0; content: ''; } .mod_select ul li{list-style-type:none;float:left;height:24px;} .select_label{color:#982F4D;float:left;line-height:24px;padding-right:10px;font-size:12px;font-weight:700;} .select_box{float:left;border:solid 1px #ccc;color:#444;position:relative;cursor:pointer;width:165px;font-size:12px;} .selet_open{display:inline-block;border-left:solid 1px #ccc;position:absolute;right:0;top:0;width:30px;height:100%;background:url(xjt.png) no-repeat 10px center;} .select_txt{display:inline-block;padding-left:10px;width:135px;line-height:24px;height:24px;cursor:text;overflow:hidden;} .option{width:165px;;border:solid 1px #ccc;position:absolute;top:24px;left:-1px;z-index:2;overflow:hidden;display:none;} .option a{display:block;height:26px;line-height:26px;text-align:left;padding:0 10px;width:100%;background:#fff;} .option a:hover{background:#aaa;}
    • sort buy:
      1
      1 2 3
    $(function(){ $(".select_box").click(function(event){ event.stopPropagation(); $(this).find(".option").toggle(); $(this).parent().siblings().find(".option").hide(); }); $(document).click(function(event){ var eo=$(event.target); if($(".select_box").is(":visible") && eo.attr("class")!="option" && !eo.parent(".option").length) $('.option').hide(); }); /*赋值给文本框*/ $(".option a").click(function(){ var value=$(this).text(); $(this).parent().siblings(".select_txt").text(value); $("#select_value").val(value) }) });运行效果图:

登录后复制

div+css模拟select下拉框实例代码

 


登录后复制

以上就是div+css模拟select下拉框实例代码的详细内容,更多请关注【创想鸟】其它相关文章!

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
编程技术

想当Web前端开发工程师你需要会什么?

2025-4-1 3:20:09

编程技术

html实现的动图之小猫笑脸

2025-4-1 3:20:18

0 条回复 A文章作者 M管理员
欢迎您,新朋友,感谢参与互动!
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
私信列表
搜索