js add jquery code example
Example 1: html how to add jquery
<!--You can insert Jquery into HTML with the <script> tag in the <head>-->
<!--Insert the next line of code into your <head> tags.-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <!-- jquery (help with javascript) -->
Example 2: add jquery in js
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = "http://code.jquery.com/jquery-2.2.1.min.js";
script.onreadystatechange = handler;
script.onload = handler;
head.appendChild(script);
function handler(){
console.log('jquery added :)');
}
Example 3: jquery add
$( "p" ).add( "div" ).addClass( "widget" );
var pdiv = $( "p" ).add( "div" );