Created
March 9, 2012 16:10
-
-
Save freshsnippets/2007285 to your computer and use it in GitHub Desktop.
JavaScript: Fix Select Dropdown Cutoff in IE7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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