Home › Forums › JavaScript › How can i simplify my ugly jQuery? (code included lol) › Re: How can i simplify my ugly jQuery? (code included lol)
May 19, 2012 at 1:56 am
#103088
Johnnyb
Member
Couldn’t you just grab the ID from whatever button’s clicked like so…
$('.navigation a').click(function(e) {
e.preventDefault();
var $self = $(this);
// some code here to hide the page if it is open...
$('.contentWrap').load($self.attr('id') + '.html', function() {
$(this).fadeIn('slow');
});
});
So long as the anchor id matches the html file name then it should load in that file. I prefer Karl’s method though so that you can link to that page directly.