Home    Articles


Introduction to jQuery


You need to know

jQuery makes easy to:

Here he have some simple HTML:

<!DOCTYPE html>
  <title>Introduction to jQuery</title>
  <h1>This is a header!</h1>
  <p>This is a paragraph.</p>

To select and return an element (h1 in this case) we simply write:


Below we can see how we change a text within a h1 node element:

$("h1").text("This is the new header")

Because jQuery may execute before the web page is loaded, we need to be sure our scripts are triggered after the page is loaded. So we need to be listening for an signal that tells us the webpage is ready to execute some scripts. To do that, we tell our function to wait for the page to be loaded, and only after that to run the code:

  $("h1").text("This is the new header");