Skip to content

Instantly share code, notes, and snippets.

@freshsnippets
Created March 9, 2012 16:10
Show Gist options
  • Save freshsnippets/2007285 to your computer and use it in GitHub Desktop.
Save freshsnippets/2007285 to your computer and use it in GitHub Desktop.
JavaScript: Fix Select Dropdown Cutoff in IE7
// 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,
top : 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
// Usage
if ($.browser.msie) {
$('select')._ie_select();
}
})(jQuery); // END SAFETY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment