Category Archives: Selecting Decorating and Enhancing

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’)

getting started

Before we can interact with HTML elements on a page, those elements need to have been loaded: we can only change them once they’re already there.

<script type=”text/javascript”>

$(document).ready(function() {
alert(‘welcome to the star to jquery…’);
});

or

$(function() {
 code goes here
});
<script>