jQuery多级联动Select下拉框介绍
本次推荐一款极具实用价值的jQuery插件,它实现了基于jQuery的多级联动省市地区Select下拉框功能。特别之处在于,该联动下拉框经过了自定义美化处理,其视觉呈现效果远胜于浏览器原生控件。此外,此Select下拉框支持绑定下拉事件,并能准确获取当前选中项的值。
HTML结构代码如下:
复制代码 代码如下:
- 湖北省
- 广东省
- 湖南省
- 四川省
- 武汉市
- 深圳市
- 长沙市
- 成都市
- 蔡甸区
- 南山区
- 雨花区
- 武侯区
CSS样式代码如下:
复制代码 代码如下: body { color: #555; font-size: 14px; font-family: "微软雅黑" , "Microsoft Yahei"; background-color: #EEE; } a { color: #555; } a:hover { color: #f00; } input { font-size: 14px; font-family: "微软雅黑" , "Microsoft Yahei"; } .wrap { width: 500px; margin: 100px auto; } .h20 { height: 20px; overflow: hidden; clear: both; } .nice-select { width: 245px; padding: 0 10px; height: 38px; border: 1px solid #999; position: relative; box-shadow: 0 0 5px #999; background: #fff url(images/a2.jpg) no-repeat right center; cursor: pointer; } .nice-select input { display: block; width: 100%; height: 38px; line-height: 38px \9; border: 0; outline: 0; background: none; cursor: pointer; } .nice-select ul { width: 100%; display: none; position: absolute; left: -1px; top: 38px; overflow: hidden; background-color: #fff; max-height: 150px; overflow-y: auto; border: 1px solid #999; border-top: 0; box-shadow: 0 3px 5px #999; z-index: 9999; } .nice-select ul li { height: 30px; line-height: 30px; overflow: hidden; padding: 0 10px; cursor: pointer; } .nice-select ul li.on { background-color: #e0e0e0; }
代码结构十分精简,此处不再赘述细节。开发者可直接预览以体验其简洁大方的视觉效果,该方案在实际应用中非常实用。