Hi stef,

Maybe you should explicitly removing the class 'show' before asdding the class hidden:

$("#dimensions").removeClass("show").addClass("hidden")


-- Marc


stef schrieb:
Im using the code below to display / hide form fields depending on
what value is selected from a drop down list (id='category'). the
optional form fields are all hidden by default when DOM is ready,
using

$(document).ready(function() {
        $("#dimensions").addClass("hidden")
        $("#size").addClass("hidden")
        $("#language").addClass("hidden")
        $("#inthebox").addClass("hidden")
        $("#color").addClass("hidden")

});

when i select "games", the p's with id 'dimensions' and 'inthebox'
appear - so far so good. when i then select "accessoires",
'dimensions' and 'inthebox' should get hidden by adding the class
'hidden' (.hidden{display:none;}) - but this never works! any ideas
why? firebug shows no errors ...

$(document).ready(function()
{
        $("#category").change( function()
                {
                        if ($("#category").val() == "games")
                        {
                                $("#dimensions").addClass("show")
                                $("#inthebox").addClass("show")


                        }

                        else if ($("#category").val() == "accessoires")
                        {
                                $("#dimensions").addClass("hidden")
                                $("#inthebox").addClass("hidden")

                        }
                });
});


Reply via email to