I would like to know how to load the jQuery library with pure Javascript and run something simple with jQuery after its loading?
My code looks like this:
function colocaScript(){
var scriptJquery = document.createElement('script')
scriptJquery.type = 'text/javascript';
scriptJquery.src = "http://code.jquery.com/jquery-1.10.2.min.js";
scriptJquery.async = true;
headHTML = document.getElementsByTagName('head')[0];
headHTML.insertBefore(scriptJquery,headHTML.firstChild);
}
colocaScript()
$(document).ready(function () {
alert("Ola Mundo");
})
It returns this error:
Uncaught ReferenceError: $ is not defined