Sample code “Hello World” – JQuery

JQuery Hello world Example

  • To do this, we register a ready event for the document.

$(document).ready(function() {

// do stuff when DOM is ready

});

  • Add following HTML snippet :

<a>Link</a>

  • Now update the $(document).ready handler:

$(document).ready(function() {

$("a").click(function() {

alert("Hello world!");

});

});

  • This is similar to the following code:

<a onclick="alert('hello world');">Link</a>