Try this using your naming scheme:
$('#experience_nav, #aboutme_nav, #recentclients_nav, #contactme_nav').click(function() {
var id = '#content_' + $(this).attr('id').replace("_nav","");
$('#contentWrap').load('files.html ' + id, function() {
$(this).hide().fadeIn();
$(id).siblings().fadeOut();
});
return false;
});
Alternatively, as light as possible, as it connects several times:
$('[id$=_nav]').live('click', function() {
var id = '#content_' + $(this).attr('id').replace("_nav","");
$('#contentWrap').load('files.html ' + id, function() {
$(this).hide().fadeIn();
$(id).siblings().fadeOut();
});
return false;
});
source
share