如何从数组中获取每个硬编码选择器并使用 jQuery hide() 方法隐藏它?
function hideAllExcept(except) {
//Create an array to contain all of the sub navigation elements
var sub_navigation = new Array();
//Get each sub ul element of the main ul and push it to the previously created array
$('#navigation_sub ul').each(function(index, element) {
sub_navigation.push('$("#' +this.id+'")');
});
var x = sub_navigation.length;
for(var i = 0; i < x; i++) {
$(sub_navigation).each(function(index, element) {
$(sub_navigation)[0].hide();
alert(element);
alert(this);
this.hide();
})
}
}