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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:24:50+00:00 2026-05-28T06:24:50+00:00

I may be going about this the wrong way. I have a container of

  • 0

I may be going about this the wrong way. I have a container of links and form options. When clicking on links it selects an option. In order to deselect the option if another is selected I need to iterate up the parent elements until a specific class and then remove the selected value for that option.

Here is some of the HTML.

<ul class="cssClass">
  <li><div class="first-elem">Select<span></span></div>
    <ul>
        <li><a href="#firstValue">First Value</a></li>
        <li><a href="#secondValue">Second Value</a></li>
    </ul>
  </li>
  <li>
    <select name="someSelect">
        <option value="">Select</option>
        <option value="firstValue">First Value</option>
        <option value="secondValue">Second Value</option>
    </select> 
  </li>
</ul>

Here is the start of the jQuery. Everything is working except my removeAttr part so I have excluded the rest.

$(".cssClass li a").click(function(e) {
  e.preventDefault();
    $(this).parentsUntil('.cssClass','option').removeAttr("selected");

But this is not working. Is there another way to do this?

  • 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-28T06:24:51+00:00Added an answer on May 28, 2026 at 6:24 am

    The second argument of parentsUntil is to filter, not to make a selection query.
    Better use this

     $(this).closest('.cssClass').find('option').removeAttr("selected");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I may be going about this the wrong way, so I'll set out the
I may be going about this backwards... I have a class which is like
I'm new to Python so I may be going about this completely wrong, but
I'm probably going about this all wrong, but hey. I am rendering a large
I have a friendly argument going on with a co-worker about this, and my
Alright, I am going to state up front that this question may be too
This really is an architectural question. I feel like I'm going about this the
Simple question, the answer may not be... I'm going to be developing a web
may i know how to use this getMicrophone with simpleFLVWriter to create flv with
I'm trying to wrap my brain about how to do this. We need to

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.