No warning message when document.ready - jQuery

This is my code:

$(document).ready(function() { alert("I am an alert box!"); }); 

when I refresh the page, there is no warning window. Are there any errors?

jQuery seems to be added correctly, but I can't get a warning to test jQuery work. Any ideas on how to make an alert show?

+6
source share
6 answers

This should work if you downloaded jQuery and you did not use noConflict . He works here , for example.

We cannot help without additional information, but here are some tips:

  • Look at your JavaScript console for errors. Most likely there is a syntax error elsewhere on the page that prevents code from ever running from running.
  • Make sure you download jQuery correctly.
  • If you are using noConflict , change $ to jQuery in your code:

     jQuery(document).ready(function() { /* ... */ }); 
+6
source

Did you enable the jQuery library before calling in the document?

 <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> ... <script type="text/javascript"> $(document).ready(function() { alert("I am an alert box!"); }); </script> 
+6
source

This should definitely work. Be sure to download jQuery before invoking these snippets.
Take a look at the javascript console for any error

+1
source

Some features:

  • jquery doesn't overlap
  • the script has a typo
  • you may have another javascript that creates the problem.
0
source

Try using:

 (function($) { $(document).ready(function() { alert("I am an alert box!"); } })(jQuery); 

If this doesn't work as well as the other answers, then check firebug for errors. You can find it here if you are not already using it.

0
source

You just need to include the jQuery file in your html page. put the link below on the html page and you will have what you want:

0
source

Source: https://habr.com/ru/post/904895/


All Articles