<button type="button" id="btn_load">load jQuery</button>
<p id="msg"></p>
function loadJS(_url, _loadedFunc){
const add_script = document.createElement('script');
add_script.src = _url;
add_script.onload = _loadedFunc;
document.body.appendChild(add_script);
}
document.getElementById('btn_load').addEventListener('click',function(){ loadJS('https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js', function(){
alert('JS LOADED!');
$('#msg').html('This text was written using jQuery.')
});
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.