Link to home
Start Free TrialLog in
Avatar of glepiza
glepiza

asked on

jquery display hidden elements

Hello experts

I am trying to do the following. After you select an item under #type-shirts, the next menu option (#types-shirt)is suppose to display (it is set to none on the style sheet), but my code is just not working. Can someone please guide me?

thanks in advance.

html:
      <p id="types-shirts">
            <select>
                  <option value="">Select type shirt</option>
                  <option value="1">1</option>
                  <option value="2">2</option>
                  <option value="3">3</option>
                  <option value="4">4</option>
            </select>
      </p>
      <p id="types-pants">  //this one has a style: display:none
            <select>
                  <option value="">Select type pants</option>
                  <option value="1">1</option>
                  <option value="2">2</option>
                  <option value="3">3</option>
                  <option value="4">4</option>
            </select>
      </p>

js:      
            if ($('#types-shirts').val() != ''){
                  $("#types-pants").css("display","block");
            }
Avatar of leakim971
leakim971
Flag of Guadeloupe image

You may check the option value :

$("#types-shirts").change(function() {
			$("option[value!='']", "#types-shirts").is(":selected")?$("#types-pants").show():$("#types-pants").hide();
		});

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of glepiza
glepiza

ASKER

oh wow, that was quick. I am learning a lot here, I was looking at so many functions and never saw CHANGE. that is a great one.

Thanks so much.
Avatar of glepiza

ASKER

I even understood the logic which is what I like more about this. today is a good learning day.
Avatar of glepiza

ASKER

thanks a lot for that, I do appreciated. Sometimes I just need someone to guide me. Thanks :)
eh eh I understand you! Have fun!