Friday, June 8, 2012

jQuery <=> JavaScript

A simple comparison on jQuery notations with classic JavaScript;
 
1.       How to refer to the DOM?
jQuery:
$(document)
JavaScript:
document

2.       Page Load

jQuery:
$(document).ready(function(){ … });
JavaScript:
Window.onload = function(){  … };

3.       How to refer to an element in the page by Id?
jQuery:
$(“#ELEMENT_ID”);
JavaScript:
document.getElementById(“ELEMENT_ID“);

4.       How to refer to the elements in a page by tag name?

jQuery:
$(“input”);
JavaScript:
    document.getElementsByTagName(“input”);