0

I am trying to call a function called gallery_image_slider() from within the $(document).ready(function() function.

Here is what I tried, but doesn't work.

$(document).ready(function() {

                gallery_image_slider();
            });

            function slider() {

                $('.projects_gallery ol').click(function() {
                    $("p.projects_gallery ol:first").addClass("intro");
                });

            function gallery_image_slider() {

                $('.project_desc_2').hide();
                 $('#project2').hide();
                 $('#description2').hide();

                 $('#project1').hover(function() {
                    $('#description1').show();
                   $('.project_desc_1').show();

                     $('.project_desc_2').hide();
                     $('#description2').hide();
                  });

                $('#project2').hover(function() {
                    $('#description2').show();
                 $('.project_desc_2').show();
                $('.project_desc_1').hide();
                        });


                $('#project1').mouseleave(function() {
                 $('.project_desc_2').hide();
                 $('#description2').hide();
                });     

                $('#project2').mouseleave(function() {
                 $('.project_desc_1').hide();
                 $('#description1').hide();
                }); 

            }
            }

How can I do this and also, how do I call multiple functions within another function?

1 Answer 1

2

you just have syntax errors, you can easily call multiple functions from document ready

        $(document).ready(function() {

            gallery_image_slider();
            slider(); // <-- do this if you want to, calling multiple function is easy
        });

        function slider() {

            $('.projects_gallery ol').click(function() {
                $("p.projects_gallery ol:first").addClass("intro");
            });
        }  // you missed this

        function gallery_image_slider() {

            $('.project_desc_2').hide();
             $('#project2').hide();
             $('#description2').hide();

             $('#project1').hover(function() {
                $('#description1').show();
               $('.project_desc_1').show();

                 $('.project_desc_2').hide();
                 $('#description2').hide();
              });

            $('#project2').hover(function() {
                $('#description2').show();
             $('.project_desc_2').show();
            $('.project_desc_1').hide();
                    });


            $('#project1').mouseleave(function() {
             $('.project_desc_2').hide();
             $('#description2').hide();
            });     

            $('#project2').mouseleave(function() {
             $('.project_desc_1').hide();
             $('#description1').hide();
            }); 

        }
          // <-- removed extra curly bracket
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! Completely missed it!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.