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

  • Home
  • SEARCH
  • 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 8390453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:59:28+00:00 2026-06-09T18:59:28+00:00

I have an issue with some code. Basically I want to remove the first

  • 0

I have an issue with some code.
Basically I want to remove the first option from <select> using jQuery, which is working, but only for the very first select. If I have 3 dropdowns the code works only for the first one. I tried to use .each but to be honest I don’t really know where and will this even help.
This is a html:

      <select class="checkb" name="gender">
     <option disabled value="">Gender</option>
     <option value="male">Male</option>
     <option value="female">Female</option>
  </select>  

  <select class="checkb" name="age">
     <option disabled value="">Age</option>
     <option value="under 13">Under 13</option>
     <option value="13-17">13-17</option>
     <option value="18-24">18-24</option>
     <option value="25-44">25-44</option>
     <option value="45-64">45-64</option>
     <option value="65+">65+</option>
  </select>  

  <select class="checkb" name="cinema">
     <option disabled value="">Select your cinema</option>
     <option value="001">Cinema 1</option>
     <option value="002">Cinema 2</option>
     <option value="003">Cinema 3</option>
  </select> 

and this is jquery:

    $(".checkb option:first").attr('hidden','hidden');

It perfectly hides the ‘Gender’ text, but doesn’t hide ‘Age’ and ‘Select your cinema’.

Thank you in advance.

  • 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-09T18:59:29+00:00Added an answer on June 9, 2026 at 6:59 pm

    That selector will select the first <option> element it finds that’s within an element with the class .checkb, which is why it’s only removing the first <option> from the first <select>.

    You could instead use the :nth-child() selector to get all <option> elements that are the first child of the <select> with that class:

    $('.checkb option:nth-child(1)').attr('hidden', 'hidden');
    

    Edit: I was curious about the efficiency of three approaches to solving this (the two suggested in the current answers, as well as a third that’s a variation of Christopher Kenney’s answer) so decided to test it. You can see the results here.

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

Sidebar

Related Questions

I have been working on some jQuery code for an interactive map. I've already
I have been using this code, but have been running into some memory issues:
I have some urgent issue which I could not find answer for across the
I have an issue with System.Threading.Timer. I am scheduling some actions using a time
I'm using XPreformatted to print some preformated text and I have an issue with
I'm writing some code that will get executed before the DOM loads, basically, using
I want to compile code conditionally based on a macro. Basically I have a
i'm writing some code that basically receive data from socket, perform deserialization and then
Basically I have a static custom queue of objects I want to process. From
I have an issue with some HTML displayed in Drupal, but I am not

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.