/** * selectfilter --v1.1 * * author: 840399345@qq.com * * $(el).selectfilter(options); * * options={ * callback : function (res){} // 返回选中的值 进行事件操作 * } * * 也可以放在表单直接获取 select标签的 值 * **/ ;jquery.fn.selectfilter = function (options){ var defaults = { callback : function (res){} }; var ops = $.extend({}, defaults, options); var selectlist = $(this).find('select option'); var that = this; var html = ''; // 读取select 标签的值 html += ''; $(that).append(html); $(that).find('select').hide(); //点击选择 $(that).on('click', '.filter-text', function (){ $(that).find('.filter-list').slidetoggle(100); $(that).find('.filter-list').toggleclass('filter-open'); $(that).find('.icon-filter-arrow').toggleclass('filter-show'); }); //点击选择列表 $(that).find('.filter-list li').not('.filter-disabled').on('click', function (){ var val = $(this).data('value'); var valtext = $(this).find('a').html(); $(that).find('.filter-title').val(valtext); $(that).find('.icon-filter-arrow').toggleclass('filter-show'); $(this).addclass('filter-selected').siblings().removeclass('filter-selected'); $(this).parent().slidetoggle(50); for(var i=0; i