Going deeper

Let's discuss jQuery functions/methods that we use frequently in detail.

All the methods should be written in the ready() function. Some of the commonly used methods are as follows:

  • Load
  • Keyup
  • Keydown
  • Change
  • Focus
  • Blur
  • Resize
  • Scroll

The load() method

Using this method, you can load a file on your browser. Consider that you want to fetch some text from a .txt file on your browser. You can do the following coding:

<html>
  <head>
    <script type="text/JavaScript" src="jquery.js"></script>
  </head>
  <script>
    $(document).ready(function(){
      $("button").click(function(){
        $("#click").load("test.txt");
      });
    });
  </script>
  <body>
    <div id="click">
      Hello;
    </div>
    <button type="button" name="button">Click to replace "Hello" from text file</button>
  </body>
</html>

Get JavaScript Projects for Kids now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.