jQuery: Using The Basic Selectors

We will start with the element selector:

$(document).ready(function() {
$("p").hide();
});

In here we selected all the “p” elements and hid them, there are other built-in functions that we will be discussing in the future posts.

The second basic selector, is the “#id” selector, which is the following:

$(document).ready(function() {
$("#headerOne").hide();
});

So this selects the element with the id of “headerOne” and hides it. The third basic selector is the “.class” selector:

$(document).ready(function() {
$(".navigationClass").hide();
});

Selects any element with the class: navigationClass. And finally, the “*” selector, selects all the elements:

$(document).ready(function() {
$("*").hide();
});

These were the basic selectors, for a full reference on jQuery selectors, visit this link.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s