This code is supposed to get the id from a clicked anchor tag in the middle of a ul with the id 'links' and then use that id for other purposes across the page, however the alerts have shown me that I keep getting 'undefined' as if the element has no id. I double check my source code and they do indeed have ids, so I'm not sure what the problem is.
$(function() {
$('ul#links > li > a').click(function() {
var planet = $(this).id;
alert(planet);
$('#planet').removeClass();
$('#planet').addClass('planet');
var bg = 'black url(../img/' + planet + '.jpg) fixed no-repeat center';
alert(bg);
$('body').css('background', bg);
});
});
Also this Jquery function is being used as a Javascript way of handling this kind of situation. I already had implemented a PHP solution which involved being redirected to a quick script that sets a cookie and returns the user to the previous page, then using the cookie to load a new CSS. Is there a way I could use that method as a backup to the JS method in the case that JS is disabled?
The page - http://schnell.dreamhosters.com/folio/