JQuery: jquery.select.1.3.6.js 下拉组件样式自定义问题修正

/**jquery的select组件对于自定义样式上无法实现,只能实现宽设定,且不能自定义下拉项的样式**/

/**做如下修正使组件可以实现对宽高、文字位置的自定义,同时下拉项与组件样式定义保持一致**/

 

sSelect: function(_change, liStyle) {


  return this.each(function(i,obj){
    ......

    $('#'+selectId+' h4').empty().append($('#'+selectId+' option:selected').text());
    var selectWidth=$('#'+selectId+' select').width();

    //增加原select的style样式与jquery组件新式同步

    var selectHeight=$('#'+selectId+' select').height();
    var selectPleft=$('#'+selectId+' select').css("padding-left");
    var selectPtop=$('#'+selectId+' select').css("padding-top");
    if($.browser.safari){selectWidth = selectWidth+15}
    $('#'+selectId+' h4').css({width:selectWidth})
    if(null != selectHeight){
        $('#'+selectId+' h4').css({height:selectHeight});
    }
    if(null != selectPleft){
        $('#'+selectId+' h4').css("padding-left",selectPleft);
    }
    if(null != selectPtop){
        $('#'+selectId+' h4').css("padding-top",selectPtop);
    }
    //-->
  var selectUlwidth = selectWidth + parseInt($('#'+selectId+' h4').css("padding-left")) + parseInt($('#'+selectId+' h4').css("padding-right"));
  ......

  .bind("click",function(e){

          ......

          $('#'+selectId).css({'position':'relative','z-index':'999'});

          //更新内容 <!--
          $.fn.setSelectValue(selectId, {width:selectWidth,height:selectHeight,pleft:selectPleft,ptop:selectPtop});
          //-->

          selectIndex = $('#'+selectId+' li').index($('.selectedli')[0]);

          ......

 

//更新内容 <!--

setSelectValue:function(sID, liStyle){
    var content = [];
    $.each($('#'+sID+' option'), function(i){
        if (liStyle != null){
            var style = "";
            if(null != liStyle.width) style += "width:"+liStyle.width+";";
            if(null != liStyle.height) style += "height:"+liStyle.height+";";
            if(null != liStyle.pleft) style += "padding-left:"+liStyle.pleft+";";
            if(null != liStyle.ptop) style += "padding-top:"+liStyle.ptop+";";
            content.push("<li class='FixSelectBrowser' style='"+style+"'>"+$(this).text()+"</li>");
        }else{
            content.push("<li class='FixSelectBrowser'>"+$(this).text()+"</li>");

        }
   });
   content = content.join('');
   $('#'+sID+' ul').html(content);
   $('#'+sID+' h4').html($('#'+sID+' option:selected').text());
   $('#'+sID+' li').eq($('#'+sID+' select')[0].selectedIndex).addClass("over").addClass("selectedli");

},

//-->

......

 

  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值