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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:52:25+00:00 2026-05-20T16:52:25+00:00

I want to hide a class of a DIV when a specific OPTION Value

  • 0

I want to hide a class of a DIV when a specific OPTION Value is selected

    <select id="tagtype" name="type">
        <option value="type_s">Standard</option>
        <option value="type_o">Overstock</option>
        <option value="type_snd">Scratch &amp; Dent</option>
        <option value="type_mult">Multiples</option>
    </select>

<div class="multiples>stuff here</div>

<script type="text/javascript"> 
$(document).ready(function() {
  if ($("#tagtype option[value='type_mult']").length)
   $("multiples").css('display','none');

});
</script>
  • 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-20T16:52:26+00:00Added an answer on May 20, 2026 at 4:52 pm

    A better way to do this would probably be something like the following:

    jQuery(document).ready(function() {
       jQuery("#tagtype").change(function() {
          if(jQuery(this).find("option:selected").val() == "type_mult") {
             jQuery(".multiples").hide();
          }
       });
    });
    

    You’re binding a handler to the onChange event of the select box. Whenever, you select a new option in the select box, the handler is called.

    In the handler, this refers to the select box that fired the onChange event. You look for the value of the selected option. If this value is equal to “type_mult”, you hide all elements with the class multiples.

    The problem with your existing code is that it will only run once; when the page first finishes loading. You need to respond to changes in the select box, which is why you need to bind to the onChange event. Another problem is the if statement. Even if you used your code and in an onChange handler, it enter the if block every type because you are not checking to see if the option with the “type_mult” value is selected. You’re simply checking to see if it exists. Since it always exists, the code inside the if will always run. Also, when you want to use class names, you need to put a period in front of the class name. So you want to do $(.multiples) and not just $(multiples) (the latter will search for a tag named multiples, which is not what you want).

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

Sidebar

Related Questions

I want to hide the selected item from the opened WPF combo box, basically
I have the following html code: <div class=result hide id=userNameTooShort><span class=error>Your username needs to
I have a div I want to hide when clicking outside it. It almost
I have the following HTML code: <fieldset> <legend><span>Contact Details</span> <span class=edit1>Edit</span><span class=hide1>Hide</span></legend> <div> <!--content-->
I'm want to have a div with class a to be invisible. I've tried
I have some nested tables that I want to hide/show upon a click on
I want to dynamically hide/show some of the columns in a NSTableView, based on
Bascially I want to know the best way to hide/show an ASP.NET control from
Hi i embed a video in my html page and i want to hide
<div class=post-content> <p>XYZ</p> <h4></h4> <p>XYZ</p> <h4></h4> <p>XYZ</p> <h4></h4> <p>XYZ</p> <h4></h4> <p>XYZ</p> <h4></h4> </div> Now

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.