Welcome Guest, Not a member yet? Register   Sign In
trying to call javascript
#5

Try adding the function to a var

Code:
/**
* Document   : web-app.js
* Author     : aka (InsiteFX)
*
* save as : js/web-app.js
*/

var webApp = function() {
    
    /* Scroll to top functionality */
    var scrollToTop = function() {

        // Get link
        var link = $('#to-top');

        $(window).scroll(function() {
            // If scrolled 150 pixels show the link
            if ($(this).scrollTop() > 150) {
                link.fadeIn(100);
            } else {
                link.fadeOut(100);
            }
        });

        // On click go to top of page
        link.click(function() {
            $('html, body').animate({scrollTop: 0}, 200);
            return false;
        });
    };
    
    // Initialize all functions here by name...
    return {
        init: function() {
            // Scroll to top (var scrollToTop = function(){})
            scrollToTop();
            
            // add other functions below here.
        }
    };

}();

// Initialize WebApp when page first loads
$(function() {
    webApp.init();
});
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
trying to call javascript - by richb201 - 05-07-2019, 03:05 PM
RE: trying to call javascript - by php_rocs - 05-07-2019, 07:03 PM
RE: trying to call javascript - by richb201 - 05-07-2019, 10:37 PM
RE: trying to call javascript - by richb201 - 05-08-2019, 05:34 AM
RE: trying to call javascript - by InsiteFX - 05-08-2019, 08:33 AM
RE: trying to call javascript - by richb201 - 05-09-2019, 09:32 AM
RE: trying to call javascript - by InsiteFX - 05-09-2019, 02:28 PM
RE: trying to call javascript - by richb201 - 05-09-2019, 04:11 PM
RE: trying to call javascript - by InsiteFX - 05-10-2019, 03:31 AM
RE: trying to call javascript - by richb201 - 05-10-2019, 06:04 AM
RE: trying to call javascript - by includebeer - 05-10-2019, 11:02 AM
RE: trying to call javascript - by richb201 - 05-10-2019, 03:56 PM
RE: trying to call javascript - by InsiteFX - 05-10-2019, 08:23 AM
RE: trying to call javascript - by Wouter60 - 05-10-2019, 10:46 AM
RE: trying to call javascript - by includebeer - 05-11-2019, 05:49 AM
RE: trying to call javascript - by InsiteFX - 05-11-2019, 08:18 AM
RE: trying to call javascript - by includebeer - 05-11-2019, 02:16 PM



Theme © iAndrew 2016 - Forum software by © MyBB