1$(document).ready(function(){
2 if (jQuery) {
3 // jQuery is loaded
4 alert("Yeah!");
5 } else {
6 // jQuery is not loaded
7 alert("Doesn't Work");
8 }
9});
1if (typeof jQuery == "undefined") {
2 alert("JQuery is not installed");
3} else {
4 alert("JQuery is installed correctly!");
5}
1/* Answer to: "test if jquery works" */
2
3window.onload = function() {
4 if (window.jQuery) {
5 // jQuery is loaded
6 console.log("jQuery has loaded!");
7 } else {
8 // jQuery is not loaded
9 console.log("jQuery has not loaded!");
10 }
11}
1window.onload = function() {
2 if (window.jQuery) {
3 // jQuery is loaded
4 alert("Yeah!");
5 } else {
6 // jQuery is not loaded
7 alert("Doesn't Work");
8 }
9}
1window.onload = function() {
2 if (window.jQuery) {
3 // jQuery is loaded
4 alert("Yeah!");
5 } else {
6 // jQuery is not loaded
7 alert("Doesn't Work");
8 }
9}
10
1jQuery offers several ways to attach a function that will run when the DOM is ready. All of the following syntaxes are equivalent:
2
3$( handler )
4$( document ).ready( handler )
5$( "document" ).ready( handler )
6$( "img" ).ready( handler )
7$().ready( handler )