/** * 动态加载JS * url JS路径 * callback 回调函数 */ function dynamicLoadJs(url, callback) { var head = document.getElementsByTagName('head')[0]; var script = document.createElement('script'); script.type = 'text/javascript'; script.src = url; if(typeof(callback)=='function'){ script.onload = script.onreadystatechange = function () { if (!this.readyState || this.readyState === "loaded" || this.readyState === "complete"){ callback(); script.onload = script.onreadystatechange = null; } }; } head.appendChild(script); } // 调用方法 dynamicLoadJs('/js/housech/menu/iscroll.js',function(){}); dynamicLoadJs('/js/housech/menu/navbarscroll.js',function(){}); $(function(){ $('#wdemo07').navbarscroll({ defaultSelect:0, scrollerWidth:3, fingerClick:0, endClickScroll:function(obj){ // console.log(obj.text()) } }); })