foreach of while loop with jquery

foreach of while loop with jquery

hi

im struggling abit i am looking to make my code expandable but i am not sure how to do it as regards to jquery in php i would do a while or foreach loop can someone help me with this.

here is my code.

$("ul.tabs li a").click(function (event) {
 
           
            // slide all content up
            $(".content").slideUp();
           
            // slide this content up
            var content_show = $(this).attr("id");
           
           
           
            if (content_show == 'tab_1') {
            $('#content_1').slideDown();
            $('ul.tabs li a#tab_1').addClass('active');
            }
           
            if (content_show == 'tab_2') {
            $('#content_2').slideDown();
            $('ul.tabs li a#tab_2').addClass('active');
            }
           
            if (content_show == 'tab_3') {
            $('#content_3').slideDown();
            $('ul.tabs li a#tab_3').addClass('active');
            }
           
            if (content_show == 'tab_4') {
            $('#content_4').slideDown();
            $('ul.tabs li a#tab_4').addClass('active');
            }
           
            if (content_show == 'tab_5') {
            $('#content_5').slideDown();
            $('ul.tabs li a#tab_5').addClass('active');
            }
           
         
        });

as you can see i have to keep adding an extra if statement everytime i add an item i need this to happen automatically. the id's and classes ae getting pulled in from a while loop in php. but stuck as far as the jquery goes.

Help please???