Running into some weird issue, can’t quite figure out what’s wrong. No errors popping up on my console.
I’m trying to filter my selector with a variable as it’s class. See jsFiddle and below
Thanks!
http://jsfiddle.net/danielredwood/SUxQx/2/
JavaScript:
$('.titles li').click(function() {
$(this).addClass('selected').siblings().removeClass('selected');
var selected = $(this).attr('class').replace(' selected', ''),
next = $('.lyrics article').hasClass(selected);
$('#w').html(selected); //for testing, shows what the value is
$('#x').html(next); //ditto
$('.shown').fadeOut(400, function() {
$(this).removeClass('shown');
next.fadeIn(400).addClass('shown');
});
});
Pretty sure this:
…should be this:
…since
.hasClass()returns a boolean.Or you could do this instead (gives the same result):
JSFIDDLE DEMO