开发者

Is there a way to edit this script so that it only applies to a specific select class?

Is there a way to edit this script so that it only applies to a specific select class and not to all tags within a page?

(This script is for expanding the dropdown list options so that they're not cut-off in IE.) What we want to happen is to apply this only to select tags that have very long option names.

<script>// Safely use $
    (function($) {

      $.fn._ie_select=function() { 

        return $(this).each(function() { 

          var a = $(this),
              p = a.parent();

          p.css('position','relative');

          var o = a.position(),
              h = a.outerHeight(),
              l = o.left,
              t = o.top;

          var c = a.clone(true);

          $.data(c,'element',a);

          c.css({
            zIndex   : 100,
            height   : h,
            to开发者_StackOverflowp      : t,
            left     : l,
            position : 'absolute',
            width    : 'auto',
            opacity  : 0
          }).attr({
            id    : this.id + '-clone',
            name  : this.name + '-clone'
          }).change(function() {
            $.data(c,'element')
              .val($(this).val())
              .trigger('change')
          });

          a.before(c).click(function() { 
            c.trigger('click');
          });

        }); // END RETURN

      }; // END PLUGIN

      if ($.browser.msie) {
        $('select')._ie_select();
      }

    })(jQuery); // END SAFETY</script>


The code at the bottom appears to be the part taking the selector, so change

if ($.browser.msie) {
   $('select')._ie_select();
}

to

if ($.browser.msie) {
   $('select.classNameHere')._ie_select();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜