I'm trying to select several list elements based on a variable in the jquery selector like so:
var testCase = jQuery.trim('li.' + $.trim(menu_type));
$('#sidebar-wrapper').find(testCase).show();
menu_type is a variable produced earlier in the code.
it works fine on firefox/chrome/safari but not on ie8... I searched on google and here for this problem, but didn't find a solution that worked for me. :(
edit: here is more code, explaining what i'm trying to do (sorry for the little information before):
$('select#menu_select_event').change(function(event) {
var menu_type = "";
var $classList = $(this).find(":selected").classList();
for (var i = $classList.length - 1; i >= 0; i--) {
if ($classList[i].length > 4 && $classList[i].substr(-4) === "Menu") {
menu_type = $classList[i];
};
};
var testCase = jQuery.trim('li.' + menu_type);
$('#sidebar-wrapper').find(testCase).show();
$('#sidebar-wrapper').find(testCase).first().find('a').trigger('click');
$('#sidebar-wrapper').find('li').not('.' + menu_type).hide();
if (menu_type == 'allMenu') {
$('#menu_type_explanation').text("通常と弁当メニュー");
} else {
$('#menu_type_explanation').text(jpfy($.trim(menu_type)) + "メニュー");
}
});
classList() is a jquery plugin I wrote. What I just found out: menu_type is actually empty on ie8, so I think
$(this).find(":selected")
doesn't work on IE8? Is there something else I could use that definitely works on IE8 as well?