Created
May 13, 2011 15:17
-
-
Save firebelly/970719 to your computer and use it in GitHub Desktop.
jquery bug in IE for selecting field set to display
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
$('#exhibitor_exhibitor_registration_level_id').bind('change', function(){ | |
var selected_index = $(this).get(0).selectedIndex; | |
var type = $(this).get(0).options[selected_index].text.split(':')[0].toLowerCase().trim(); | |
var type_name = type.match(/school/) ? "school" : "business"; | |
$(".entity_name").hide(); | |
$("." + type_name).show(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
and the fix is (mostly because IE does not implement trim() for some inexplicable reason):
$('#exhibitor_exhibitor_registration_level_id').bind('change', function(){
var selected_index = $(this)[0].selectedIndex;
var type = $($(this)[0].options[selected_index]).text();
type = $.trim(type.split(':')[0].toLowerCase());
var type_name = /school/.test(type) ? "school" : "business";
$(".entity_name").hide();
$("." + type_name).show();
});