Reputation:
I have the following code that is not working properly, what am I doing wrong???
$('#gallerynav ul li a').click(function(){
var href = $('#gallerynav ul li a').attr('href')
$("#galleries").children().fadeOut(500 , function(){
(href).fadeIn(500)
})
})
I have the href of the links set like this:
<div id="gallerynav">
<ul>
<li><a href="#foo">link</a></li>
</ul>
</div>
Upvotes: 0
Views: 10585
Reputation: 945
Try this.
$('#gallerynav ul li a').click(function(){
var link = $(this).attr('href');
$("#galleries").children().fadeOut(500 , function(){
$(link).fadeIn(500);
});
});
Upvotes: 6
Reputation: 1038850
Try this:
$('#gallerynav ul li a').click(function(evt) {
var href = this.href;
$("#galleries").children().fadeOut(500 , function() {
$(href).fadeIn(500);
});
evt.preventDefault();
});
Upvotes: 1
Reputation: 321
I think: var href = $('#gallerynav ul li a').attr('href');
should be: var href = this.attr('href');
Upvotes: 0
Reputation: 11127
It looks like you're missing a $ in front of the (href) call. Try:
$(href).fadeIn(500)
Upvotes: 0