(function($){ var selects=$('select');//获取select for(var i=0;i');//div相当于select标签 tag_select.attr('class','select_box'); tag_select.insertbefore(select_container); //显示框class为select_showbox,插入到创建的tag_select中 var select_showbox=$('
');//显示框 select_showbox.css('cursor','pointer').attr('class','select_showbox').appendto(tag_select); //创建option容器,class为select_option,插入到创建的tag_select中 var ul_option=$('');//创建option列表 ul_option.attr('class','select_option'); ul_option.appendto(tag_select); createoptions(index,ul_option);//创建option //点击显示框 tag_select.toggle(function(){ ul_option.show(); ul_option.parent().find(".select_showbox").addclass("active"); },function(){ ul_option.hide(); ul_option.parent().find(".select_showbox").removeclass("active"); }); var li_option=ul_option.find('li'); li_option.on('click',function(){ $(this).addclass('selected').siblings().removeclass('selected'); var value=$(this).text(); select_showbox.text(value); ul_option.hide(); }); li_option.hover(function(){ $(this).addclass('hover').siblings().removeclass('hover'); },function(){ li_option.removeclass('hover'); }); } function createoptions(index,ul_list){ //获取被选中的元素并将其值赋值到显示框中 var options=selects.eq(index).find('option'), selected_option=options.filter(':selected'), selected_index=selected_option.index(), showbox=ul_list.prev(); showbox.text(selected_option.text()); //为每个option建立个li并赋值 for(var n=0;n'),//li相当于option txt_option=options.eq(n).text(); tag_option.text(txt_option).appendto(ul_list); //为被选中的元素添加class为selected if(n==selected_index){ tag_option.attr('class','selected'); } } } })(jquery) /*上一页 power by sly 2015-10-30*/ function prev_pages_num(){ var i = $('#pages_num').val(); i = i-1 > 0 ? i-1 : 1; $('#pages_num').val(i); } /*下一页 power by sly 2015-10-30*/ function next_pages_num(){ var i = $('#pages_num').val(); var h = $('span#total_page').text(); if (i+1 <=h) { i++; }else{ i = h; } $('#pages_num').val(i); } /*跳转到指定页*/ function goto_pages_url(){ var i = $('#pages_num').val(); var url = $('#pages_url').val(); var h = $('span#total_page').text(); if (i<1) { i=1; }; if (i > number(h)) { i=h; }; url = url.replace(/\[p\]/g, i); location.href=url; }