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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:58:57+00:00 2026-06-11T04:58:57+00:00

I have 3 select option in my html page like this <select class=combo> <option

  • 0

I have 3 select option in my html page like this

    <select class="combo">
    <option value=""></option>
    <option value="1"></option>
    <option value="2"></option>
    <option value="3"></option>
    </select>
    <br/>
    <select class="combo">
        <option value="1"></option>
    <option value="2"></option>
    <option value="3"></option>
    </select>
    <br/>
    <select class="combo">
       <option value="1"></option>
    <option value="2"></option>
    <option value="3"></option>
    </select>
<br/>
<button type="submit" class="search_btn">
                                <img src="media/images/search_icon.png" title="Search" /></button>
                            <input type="text" lang="fa" id="search" name="search"/>

I want if the first select value was NOT null, trigger an action. something like this.

if( $('.combo').has('option').length > 0 ) { 
 $('#search').val('');
}

The problem is that i don’t know how to address this action for the first select and not the second and third (because they have same class names).

Note that i don’t want to set ID to the first select in code preview

  • 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-11T04:58:59+00:00Added an answer on June 11, 2026 at 4:58 am

    You can use :first selector:

    if ( $('.combo:has(option):first').length > 0 ) { 
       $('#search').val('');
    }
    

    Note that $('.combo:has(option):first') differs from $('.combo:first:has(option)') the first one selects the first select.combo that has option element and the second one selects the first select.combo only if that has option element.

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

Sidebar

Related Questions

I have a form like this: <select> <option value=page1.html class=confirm>Page 1</option> <option value=page2.html class=confirm>Page
I have this HTML structure (excerpt): <td> <select id=test1 class=pub_chooser> <option value=99>All Publications</option> <option
I have a php page like this : <html> <body> <form method=post action=catch_combo.php> <select
I have a page that looks like this: <body> <div class=pollid > <select class=pollid
Hi I have a html select tag like this: <select name = options> <option
I have a classic HTML select box: Show: <select name=show id=showThreads> <option value=all selected=selected>All</option>
I have this HTML: <select multiple='multiple' size='3'> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> </select> Using
I have the following HTML markup: <select name=Fault class=textbox id=fault> <option>Single Light Out</option> <option>Light
I have the following code in html: <select> <option text=item9 value=9></option> <option text=item10 value=10></option>
I have the following HTML: <div data-name=countrySelectorRoot> <select> <option value=C1>Country 1</option> <option value=C2>Country 2</option>

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.