jQuery include variable as class name

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




$('.titles li').click(function() {

    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() {


Pretty sure this:

next = $('.lyrics article').hasClass(selected);

...should be this:

next = $('.lyrics article.' + selected);

...since .hasClass() returns a boolean.

Or you could do this instead (gives the same result):

next = $('.lyrics article').filter('.' + selected);


Need Your Help

How to implement help in Eclipse 4.3 (Kepler) application?

java kepler help-system

I have an E4 RCP application and I need to add a Help system to it.

expression engine: search in grid-fields does not work

search grid expressionengine fieldtype

I have built my faq-section with a grid that contains two columns, question and answer. I don't get search results from my grid-fields in entries. So my questions are unfortunately not searchable ....