jQuery Example

tutorial and example
tutorial and example

Hello, world! Example

Here is the jQuery first example:

The above code have a div tag with the id of “divTest1” and $ shortcut to access jQuery. In this code select all elements with an id of “divTest1” and set its text to “Hello, world!”.

Use the following code if you want to do it in the plain JavaScript without the help of jQuery:

  1. <div id=“divTest2”></div>
  2. <script type=“text/javascript”>
  3. document.getElementById(“divTest2”).innerHTML = “Hello, world!”;
  4. </script>

If your HTML element didn’t have an id then it would be even longer.

Example:

Try Now