jQuery "$(...).effect is not a function"

mentinet picture mentinet · Feb 24, 2014 · Viewed 22.9k times · Source

I searched through the forum already but I can't find any way to fix the problem I have with the "effect" function in jQuery.

I get exactly the error TypeError: $(...).effect is not a function in the code :

$('div.step').removeClass('active');
$("div.step").effect('slide', {direction: 'right', mode: 'hide'}, 500);
$('#step' + step + '').addClass('active');
$('#step' + step + '').effect('slide', {direction: 'right', mode: 'show'}, 500);

I included both jQuery and jQuery UI like this in <head></head> :

<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

But in vain, do you have any idea? Thank you

Answer

James Donnelly picture James Donnelly · Feb 24, 2014

You need to put your custom script after your jQuery and jQuery UI declarations, and wrap it within a document ready() function:

<body>
    ...
    <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
    <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            ...
        });
    </script>
</body>