Springheeled Jack
Springheeled Jack

Reputation: 199

Changing this to a slide function jQuery

I dont know much about Javascript and im trying to change this show element script into a nicer slideToggle() motion instead of just popping up.

Currently it reveals hidden elements. The element revealed is dependent upon what id is selected in a html select list.

Here is the JS:

$('#business_type').change(function(){
        $("#common >div").each(function() {
        $(this).attr("style", "display: none;");
        })
        $("#" + $(this).val()).attr("style", "display: block;");
        })

Is there a function i can add to it just to toggle between hidden elements in a slide motion.

Upvotes: 0

Views: 25

Answers (1)

Touhid Alam
Touhid Alam

Reputation: 343

Try the jQuery show([duration]) function. In your case, considering the $("#common >div") elements are already hidden, you could try

$("#common >div").each(function(index, elem) {
    $(elem).show(500);
});

If not already hidden, you can try $(selector).hide().show(/*duration*/)

Upvotes: 1

Related Questions