Reputation: 3
please advise on what to change in syntax
$(document).ready(function(){
//click on nav
$('#nav li a').click(function() {
//set variable
var targetDiv = $(this).attr('href');
var targetPic = $(this).attr('href');
//remove # from var
targetPic = str.replace('#', '');
//hide !=var
$('div').not( + targetDiv) .hide('puff', 1000);
$('div').not('.' + targetPic) .hide('puff', 1000);
//show =var
$('div' + targetDiv) .show('puff', 1000);
$('div.' + targetPic) .show('puff', 1000);
})
});
Upvotes: 0
Views: 60
Reputation: 21864
targetPic = str.replace('#', '');
should be
targetPic = targetPic.replace('#', '');
since there is no variable str
imho
but this code will not work in browsers where $(this).attr('href');
returns the full absolute url (thiat is including http://......#
) like some versions of IE
Upvotes: 1
Reputation: 7307
To @Caspar Kleijne's answer I would also like to add that I see another mistake in your code :
$('div').not( + targetDiv) .hide('puff', 1000);
should probably be
$('div').not('#' + targetDiv) .hide('puff', 1000);
Upvotes: 1