简体   繁体   中英

how to call a jquery function within another function

i have this function:

<script type="text/javascript">

        $('.infinite-container').waypoint('infinite', {
            container: 'auto',
            items: '.infinite-item',
            more: '.infinite-more-link',
            offset: 'bottom-in-view',
            loadingClass: 'infinite-loading',
            onBeforePageLoad: $.noop,
            onAfterPageLoad: $.noop
        });

</script>

and i want to call some other functions, for example i want to call this:

    <script>
        $(document).ready(function() {
            $('.container').stickem();
        });
    </script>

and in order to call it i want to replace $.noop on the onAfterPageLoad event

would it look something like this?:

 onAfterPageLoad: $.stickem()

super new to javascript/jquery if you cant tell.

Wrap your code inside a function, which the plugin will call when the onAfterPageLoad event fires:

onAfterPageLoad: function() {
    $('.container').stickem();
}

You have to create a function and put your code inside that function. See below for an example:

function stickem(){
// your code goes here
}

and then call it like this:

onAfterPageLoad: stickem;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM