Category Archives: Selecting

Simple Selecting

jQuery(<selectors go here>)
Or the alias:
$(<selectors go here>)

Confused ..Ok

If we wanted to select every paragraph, divelement, h1heading, or input box on the page, we would use these selectors accordingly:

$(‘p’)
$(‘div’)
$(‘h1’)
$(‘input’)

jQuery borrows the conventions from CSS for referring to id and class names. To select by id, use the hash symbol (#) followed by the element’s id, and pass this as a string to the jQuery function:
$(‘#id-name’)

Similarly, we can use a CSS class selector to select by class. We pass a string consisting of a period (.) followed by the element’s class name to the jQuery function:
$(‘.data’)