这次给大家带来Jquery+HTML+CSS实现下拉列表功能,Jquery+HTML+CSS实现下拉列表功能的下拉列表有哪些,下面就是实战案例,一起来看一下。
fruit .hide { display: none;}p { float: left; width: 100%;}.selector-containter { margin-bottom: 10px;}.selector { width: 200px; background: #FFF; border: 1px solid #DDD;}.selector-hint { width: 178px; border: 1px solid #DDD;}.selector-expand { width: 8px; border: 1px solid #DDD;}.selector-collapse { width: 8px; border: 1px solid #DDD;}$(document).ready(function() { //使用on方法,采用事件委派机制,selector-option-container中的内容为后续动态追加 $('.selector').on('click', '.selector-expand', function() { $(this).parent().children('.selector-option-container').children().remove(); $(this).parent().children('.selector-option-container').append('apricot
'); $(this).parent().children('.selector-option-container').append('banana
'); $(this).nextAll('.selector-option-container').removeClass('hide'); }); $('.selector').on('click', '.selector-collapse', function() { $(this).nextAll('.selector-option-container').addClass('hide'); }); $('.selector-t1').on('click', '.selector-option', function() { $(this).parent().parent().children('.selector-hint').text($(this).text()); $(this).parent().addClass('hide'); }); $('.selector-t1').on('click', '.selector-checkbox', function() { $(this).parent().parent().parent().children('.selector-hint').text($(this).parent().next().text()); //采用prop方法,对于值为布尔型的属性赋值 $(this).prop('checked', false); $(this).parent().parent().addClass('hide'); });});
select fruit
-
select fruit
-
登录后复制
相信看了本文案例你已经掌握了方法,更多精彩请关注【创想鸟】其它相关文章!
推荐阅读:
立即学习“前端免费学习笔记(深入)”;
下拉列表
下拉列表
下拉列表
以上就是Jquery+HTML+CSS实现下拉列表功能的详细内容,更多请关注【创想鸟】其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。
发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2770447.html