我创建了一个函数appendScript,它将在按钮单击事件时被调用。我的函数代码是
function appendScript()
{var v_js;
var head= document.getElementsByTagName('head')[0];
v_js = document.createElement('script');
v_js.type = 'text/javascript';
v_js.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js';
head.appendChild(v_js);
var body = document.getElementsByTagName('body')[0];
v_js =document.createElement('script');
v_js.type="text/javascript" ;
v_js.src = "//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.2/js/bootstrap.min.js";
body.appendChild(v_js);
var v_css= document.createElement('link');
v_css.rel= "stylesheet";
v_css.type = "text/css" ;
v_css.href="http://twitter.github.io/bootstrap/1.4.0/bootstrap.min.css"
body.appendChild(v_css);
}当我点击按钮时,我得到了错误
Uncaught TypeError: Object [object Object] has no method 'on' bootstrap.min.js:6
(anonymous function) bootstrap.min.js:6
(anonymous function)谁能帮我解决这个错误??
发布于 2013-06-25 11:28:19
您的JQuery(1.5.2)版本和Bootstrap (2.3.2)版本不兼容。升级您的Jquery版本。Bootstrap正在寻找在您的版本(1.5.2)中不可用的on()。.on()可以从1.7+版本的jquery中获得。因此,请尝试将其升级到最新版本。
当您下载最新版本的时,它将为您提供1.9.1版本的jQuery包,因此您可能希望至少尝试升级到该版本,以确保一切工作正常。
https://stackoverflow.com/questions/17288668
复制相似问题