Is there more efficeint way of writing multiple functions?

Is there more efficeint way of writing multiple functions?

Hi ,

I am very exciting about jQuery but a am not programmer and the way I write functions is probably not most efficient.

For example I have 12 collapsible panel that I need to control. Is there better way of writing this?

  1. <script>
    $(document).ready(function() {
        $('.open-close').text('Read More...')
       
         $('.faq-1oc').toggle(function() {
              $(".faq-1").fadeIn();
            $(this).text('Close');
        },    
        function() {
              $(".faq-1").fadeOut();
            $(this).text('Read More...');
        });
       
        $('.faq-2oc').toggle(function() {
              $(".faq-2").fadeIn();
            $(this).text('Close');
        },    
        function() {
              $(".faq-2").fadeOut();
            $(this).text('Read More...');
        });
       
        $('.faq-3oc').toggle(function() {
              $(".faq-3").fadeIn();
            $(this).text('Close');
        },    
        function() {
              $(".faq-3").fadeOut();
            $(this).text('Read More...');
        });
       
        $('.faq-4oc').toggle(function() {
              $(".faq-4").fadeIn();
            $(this).text('Close');
        },    
        function() {
              $(".faq-4").fadeOut();
            $(this).text('Read More...');
        });
       
        $('.faq-5oc').toggle(function() {
              $(".faq-5").fadeIn();
            $(this).text('Close');
        },    
        function() {
              $(".faq-5").fadeOut();
            $(this).text('Read More...');
        });
       
        $('.faq-6oc').toggle(function() {
              $(".faq-6").fadeIn();
            $(this).text('Close');
        },    
        function() {
              $(".faq-6").fadeOut();
            $(this).text('Read More...');
        });
       
        $('.faq-7oc').toggle(function() {
              $(".faq-7").fadeIn();
            $(this).text('Close');
        },    
        function() {
              $(".faq-7").fadeOut();
            $(this).text('Read More...');
        });
        $('.faq-8oc').toggle(function() {
              $(".faq-8").fadeIn();
            $(this).text('Close');
        },    
        function() {
              $(".faq-8").fadeOut();
            $(this).text('Read More...');
        });
       
        $('.faq-9oc').toggle(function() {
              $(".faq-9").fadeIn();
            $(this).text('Close');
        },    
        function() {
              $(".faq-9").fadeOut();
            $(this).text('Read More...');
        });
       
        $('.faq-10oc').toggle(function() {
              $(".faq-10").fadeIn();
            $(this).text('Close');
        },    
        function() {
              $(".faq-10").fadeOut();
            $(this).text('Read More...');
        });
        $('.faq-11oc').toggle(function() {
              $(".faq-11").fadeIn();
            $(this).text('Close');
        },    
        function() {
              $(".faq-11").fadeOut();
            $(this).text('Read More...');
        });
       
        $('.faq-12oc').toggle(function() {
              $(".faq-12").fadeIn();
            $(this).text('Close');
        },    
        function() {
              $(".faq-12").fadeOut();
            $(this).text('Read More...');
        });

      
     });
    </script>