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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:42:09+00:00 2026-06-12T03:42:09+00:00

Im currently using a script (that is working) where I can apply a certain

  • 0

Im currently using a script (that is working) where I can apply a certain class to a div, based on the class of another div. I would prefer to use content:contains(), to determine the class of the other div, but when I use it, it applies every class at the same time, from every if statement. The code im using is below.

// Set Olympic
            if($(".reg-status.olympic span").hasClass("open")) {
                $(".reg-status-view.olympic").addClass("open");
            }
            if($(".reg-status.olympic span").hasClass("waiting")) {
                $(".reg-status-view.olympic").addClass("waiting");
            }
            if($(".reg-status.olympic span").hasClass("closed")) {
                $(".reg-status-view.olympic").addClass("closed");
            }

            // Set Long Course
            if($(".reg-status.long-course span").hasClass("open")) {
                $(".reg-status-view.long-course").addClass("open");
            }
            if($(".reg-status.long-course span").hasClass("waiting")) {
                $(".reg-status-view.long-course").addClass("waiting");
            }
            if($(".reg-status.long-course span").hasClass("closed")) {
                $(".reg-status-view.long-course").addClass("closed");
            }

Question 1: Is there a cleaner way to do what im current trying
Question 2: How do I .addClass from content with the initial div, as appose to the class on the initial div.

Any help would be appreciated.

  • 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-12T03:42:10+00:00Added an answer on June 12, 2026 at 3:42 am

    First of all, put the searches into a reference variable to prevent re-searching the dom. second, if the source div only contains “open”,”closed”,”waiting” classes, you can copy the class attribute to the target div.

    var olySrcDiv = $(".reg-status.olympic span");
    var olyTgtDiv = $(".reg-status-view.olympic");
    olyTgtDiv.attr("class",olyTgtDiv.attr("class") + " " + olySrcDiv.attr("class"));
    
    var lngSrcDiv = $(".reg-status.long-course span");
    var lngTgtDiv = $(".reg-status-view.long-course");
    lngTgtDiv.attr("class",lngTgtDiv.attr("class") + " " + lngSrcDiv.attr("class"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a Perl CGI script that parses incoming XML requests using XML::Simple
I'm currently trying to write a script that will connect to a site using
I am currently working on a random number generator script that will generate three
The project that I'm currently working on, is large scale. I'm using email activation
Were currently working on a script that reads the current users information from out
I'm working on a script currently that needs to pull information down from a
I am currently working on a script that runs through a document, pulls out
I am currently working on a PHP script that will be polling Active Directory
I have an IronPython script that looks for current running processes using WMI. The
I am currently using the following script to set this value as a String:

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.