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 8998223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:59:42+00:00 2026-06-15T23:59:42+00:00

if i am looping through some jquery objects that are select dropdowns, how can

  • 0

if i am looping through some jquery objects that are select dropdowns, how can I get the class of the selected option using jquery’s $(this)?

elems.each(function(idx, elem) {
    if ($(this).is('select')){
        console.log($(this, "option:selected"))
    }
});

does not seem to work.

  • 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-06-15T23:59:43+00:00Added an answer on June 15, 2026 at 11:59 pm
    ​elems.each(function(idx, elem) {
        var ref = $(this); // caching $(this)
        if( ref.is('select') ) {
            console.log( ref.find('option:selected') );
    
            // OR in jQuery Context format
            console.log( $('option:selected', ref) ); // this format internally 
                                                      // called .find() method
    
            // to get the class
            console.log( ref.find('option:selected').attr('class') );
        }
    })​;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with some images from the Flickr API using jQuery, and looping through
I am looping through some elements using jQuery's .each() and I want to delete
I'm working on a site that involves looping through an array, using a jQuery
Can anyone find a more Python'ic, more beautiful solution? I’m looping through some text
So I'm looking through some code, and I see this: class whatever { public:
I'm having issues with some jQuery code I have. Using $.each I am looping
I'm looping through a form and showing content that matches my selected id's. The
I have a working jQuery script that will cycle through some images. However, when
I am looping through some unordered lists and I'd like to get all of
While looking through some old code I came across this gem: MyObject o =

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.