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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:05:33+00:00 2026-06-05T08:05:33+00:00

What is the best way to add another class to this script: <script type=text/javascript>

  • 0

What is the best way to add another class to this script:

<script type="text/javascript">
    $(document).ready(function(){
     $('.carlocation').hide();
      $('#parking-options').change(function() {
        $('.carlocation').hide();
        $('#' + $(this).val()).show();
     });
    });
</script>

I am fine with the same ID displaying this classes, I am just unsure about how to add another class to this script. As '.carlocation' , '.insertclass' or '.carlocation .insertclass' does nothing but break the script.

Thanks!

EDIT – The rest of the markup.

I would like .carlocation and .car-position to start off as two hidden divs but in the first drop down when “Self parking” is selected that the other two selections display.

<li>
                    <label for="select-choice-0" class="select">Parking Method:</label>
                    <select name="select-choice-15" id="parking-options" data-theme="b" data-overlay-theme="d" data-native-menu="false" tabindex="-1">
                       <option value="">Select One</option>
                       <option value="self">Self Parking</option>
                       <option value="auto">Valet Parking</option>
                    </select>
                </li>
                <li>
                    <div id="self" class="carlocation">
                    <h1>Enter Car Location:</h1>
                    <label for="select-choice-0" class="select">Floor:</label>
                    <select name="select-choice-15" id="location-floor" data-theme="b" data-overlay-theme="d" data-native-menu="false" tabindex="-1">
                       <option value="">Floor Select</option>
                       <option value="f1">F1</option>
                       <option value="f2">F2</option>
                       <option value="f3">F3</option>
                       <option value="f4">F4</option>
                    </select>
                    </div>
                </li>
                <li>
                <div id="self" class="car-position">
                <label for="select-choice-0" class="select">Row:</label>
                <select name="select-choice-15" id="position-row" data-theme="b" data-overlay-theme="d" data-native-menu="false" tabindex="-1">
                       <option value="">Row Select</option>
                       <option value="1">1</option>
                       <option value="2">2</option>
                       <option value="3">3</option>
                       <option value="4">4</option>
                       <option value="5">5</option>
                       <option value="6">6</option>
                       <option value="7">7</option>
                </select>
                <li>
  • 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-05T08:05:34+00:00Added an answer on June 5, 2026 at 8:05 am

    Hide your elements with CSS:

    .carlocation, .car-position {
        display: none;
    }
    

    Remove the repeated “self” id from both of the divs, and instead add the “self” value to the class attribute on both:

    <li>
        <div class="self carlocation">
            <!-- ... -->
        </div>
    </li>
    <li>
        <div class="self car-position">
            <!-- ... -->
        </div>
    </li>
    

    Side Note: Your second div was missing its closing tag.

    Then bind to the change event of the form:

    $("#parking-options").on("change", function(){
        $("div.self").toggle( $(this).val() === "self" );
    });​​​​​​​​​​
    

    This bases the visibility of all .self divs on the value of the select being “self”. If “self” is selected, all div.self items will become visible. Otherwise, they become hidden.

    Fiddle: http://jsfiddle.net/jonathansampson/5KJV5/

    Or you could slide them into view:

    $("#parking-options").on("change", function(){
        $(this).val() === "self"
            ? $("div.self").slideDown()
            : $("div.self").slideUp();
    });​
    

    Fiddle: http://jsfiddle.net/jonathansampson/5KJV5/2/

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

Sidebar

Related Questions

What is the best way to add text to the beginning of a file
What is the best way to add a sense of order in Doctrine Nested
What's the best way to add foreign keys to my existing tables in Rails
Given a large table (10-100 million rows) what's the best way to add some
What is the best way for me to add my own properties to an
the best way to explain is with example so: this is the model public
The best way I can think of to ask this is by example... In
The best way of describing this is I have a table of people with
Should have asked someone this a long time ago. What is the best way
I try adding objects to NSMutableArray from another class (secondViewController) and then add it

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.