Accessing the DOM
var q = document.getElementById("question"); ... <p id="question">Which method do you prefer?</p>
var paragraphs = document.getElementsByTagName("p");
Using jQuery Selectors to Access HTML Elements
Accessing HTML elements is one of jQuery’s biggest strengths. jQuery uses selectors that are very similar to CSS selectors to access one or more elements in the DOM, hence, the name jQuery. jQuery returns back either a single element or an array of jQuerified objects. jQuerified means that additional jQuery functionality has been added to the DOM object, allowing for much easier manipulation.
The syntax for using jQuery selectors is $(selector).action(), where selector is replaced by a valid selector and action is replaced by a jQuerified action attached to the DOM element(s).
For example, the following command finds all paragraph elements in the HTML document and sets the CSS font-weight property to bold: