请告知语法更改内容
$(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);
})
});
答案 0 :(得分:1)
targetPic = str.replace('#', '');
应该是
targetPic = targetPic.replace('#', '');
since there is no variable str
imho
$(this).attr('href');
返回完整的绝对网址(thiat包括http://......#
),就像某些版本的IE一样
答案 1 :(得分:1)
对@Caspar Kleijne的回答我还想补充一点,我在你的代码中看到了另一个错误:
$('div').not( + targetDiv) .hide('puff', 1000);
应该是
$('div').not('#' + targetDiv) .hide('puff', 1000);