Class won't be added for a specific id
I'm a novice here, and I've got such a piece of code:
-
$(document).ready(function() {
$.each(includes, function(index, value) {
$('ul#menu-list').append('<li id="' + index + '"><a href="#">' + value + '</a></li>');
}
);
$('ul#menu-list li').click(function() {
var id = $(this).attr('id');
$('ul#menu-list li').removeClass('active');
$(this).addClass('active');
$('#content').load('include/' + id + '.html', null, function() {
$('span.inline-link').click(function() {
var id = $(this).attr('id');
$('ul#menu-list li').removeClass('active');
$('#content').load('include/' + id + '.html');
--> $('ul#menu-list li#' + id).addClass('active'); <--
return false;
});
});
return false;
});
});
Basically, I load an html document on demand, through a menu populated with 'includes' values. Clicking on any item on the menu will load the appropriate document in the #content div and add an 'active' class to the menu item itself, to highlight it.
The loaded document optionally has inline links, that should load documents based on the same id's. Clicking on these inline links loads the appropriate document, but the 'active' class won't be added to the menu item having the same id of the inline link.
The thing I don't understand is that if I put (look at the line with arrows) any other value than 'id' (any valid integer or even 'id * 2') I get the desired result: a menu item having that id gets highlighted, a class being added to it.
I'm really stuck
Thanks for any help!
G.