i made a function appendScript which will be called on a button click event my function code is
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);
}
when i click on the button i am getting error
Uncaught TypeError: Object [object Object] has no method 'on' bootstrap.min.js:6
(anonymous function) bootstrap.min.js:6
(anonymous function)
can any one please help how to resolve this error ??
Your version of JQuery(1.5.2) and Bootstrap (2.3.2) are not compatible. Upgrade your version of Jquery. Bootstrap is looking for on()
which is not available in your version(1.5.2). .on()
is available from version 1.7+ of jquery. So try upgrade it to the latest version as possible.
When you download the latest version of boostrap(2.3.2) it provides you 1.9.1 version of jquery along with the package, so you may want to try upgrading at least to that version to ensure everything is working as expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With