jQuery 自定义下拉框(DropDown)附源码下载

先给大家展示下效果图,喜欢的朋友可以下载源码哦

jQuery 自定义下拉框(DropDown)附源码下载

jQuery 自定义下拉框(DropDown)附源码下载

效果演示   源码下载

<section> <div> <div tabindex="1"> <span>手册网</span> <ul tabindex=""> <li><a href="#">jQuery特效</a></li> <li><a href="#">网站模板</a></li> </ul> </div> </div> </section> </div> <script type="text/javascript" src="https://libs.useso.com/js/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript"> function DropDown(el) { this.dd = el; this.placeholder = this.dd.children('span'); this.opts = this.dd.find('ul.dropdown > li'); this.val = ''; this.index = -; this.initEvents(); } DropDown.prototype = { initEvents: function() { var obj = this; obj.dd.on('click', function(event) { $(this).toggleClass('active'); return false; }); obj.opts.on('click', function() { var opt = $(this); obj.val = opt.text(); obj.index = opt.index(); obj.placeholder.text('Gender: ' + obj.val); }); }, getValue: function() { return this.val; }, getIndex: function() { return this.index; } } $(function() { var dd = new DropDown($('#dd')); $(document).click(function() { $('.wrapper-dropdown-1').removeClass('active'); }); }); </script>

以上所述是小编给大家介绍的jQuery 自定义下拉框(DropDown)附源码下载,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wzsyjj.html