Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6895373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:54:01+00:00 2026-05-27T06:54:01+00:00

Running into some weird issue, can’t quite figure out what’s wrong. No errors popping

  • 0

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');
   });
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:54:02+00:00Added an answer on May 27, 2026 at 6:54 am

    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);
    

    JSFIDDLE DEMO

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running into some compiler errors I don't understand. I'm pretty sure I'm doing
I have been trying to learn Erlang and have been running into some problems
Trying to truncate some code here and running into a problem: <script type=text/javascript> $(function()
I'm running into some really weird problems with ctypes. I'm using ctypes to interface
I'm running into a weird thingy here. I'm trying to add a JLabel inside
So I'm running into this weird issue. When I'm developing locally, and I run
I'm running into a really weird issue with Silverlight 3. I've defined an extension
I am running into some weird behaviour with Delphi's inline assembly, as demonstrated in
Running into some weird issues with didReceiveAuthenticationChallenge. If I do something like: NSMutableURLRequest *request
I'm running into a weird issue with a crossdomain webservice call in Silverlight 4.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.