1

$(document).ready(function($)HTML ファイルには 2 つの関数があります。2 つのready()関数があるため、実行されるのは 1 つだけです。私はjQueryについてよく知らないので、それらをマージすることはできません.

<script type="text/javascript">

    $(document).ready(function($){

        $('#mega-1').dcVerticalMegaMenu({
            rowItems: '3',
            speed: 'fast',
            effect: 'show',
            direction: 'right'
        });
        $('#mega-2').dcVerticalMegaMenu({
            rowItems: '3',
            speed: 'slow',
            effect: 'fade',
            direction: 'left'
        });
        $('#mega-3').dcVerticalMegaMenu({
            rowItems: '4',
            speed: 'slow',
            effect: 'slide',
            direction: 'right'
        });
        $('#mega-4').dcVerticalMegaMenu({
            rowItems: '3',
            speed: 'fast',
            effect: 'slide',
            direction: 'left'
        });

    });
    </script>

jQuery関数2:

<script type="text/javascript">
    $(document).ready(function(){
        $("#featured > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
    });
</script>
4

1 に答える 1

1
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Page Title</title>

<script src="some_javascript_file.js"></script>
<script src="another_js_file.js"></script>

</head>
<body>

<!-- HTML HERE -->


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="jQuery_plugin_1.js"></script>
<script src="jQuery_plugin_2.js"></script>
<script>
(function($){ // remap $ to jQuery

    $(function(){
        $('#mega-1').dcVerticalMegaMenu({
            rowItems: '3',
            speed: 'fast',
            effect: 'show',
            direction: 'right'
        });
        $('#mega-2').dcVerticalMegaMenu({
            rowItems: '3',
            speed: 'slow',
            effect: 'fade',
            direction: 'left'
        });
        $('#mega-3').dcVerticalMegaMenu({
            rowItems: '4',
            speed: 'slow',
            effect: 'slide',
            direction: 'right'
        });
        $('#mega-4').dcVerticalMegaMenu({
            rowItems: '3',
            speed: 'fast',
            effect: 'slide',
            direction: 'left'
        });


        // =====================================

        $("#featured > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);

    });

})(jQuery);
</script>

</body>
</html>
于 2012-07-17T11:48:51.463 に答える