jQuery Basics Part 2

In this post I’m going to look at all the different ways you can target and select DOM elements.

Basic Selectors

$("p").css("border", "3px solid red");
$(".a").css("border", "3px solid red");
$("#list1").css("border", "3px solid red");
$("p.b").css("border", "3px solid red");

Form Selectors

$("form :input").css("border", "3px solid red");
$("form :text").css("border", "3px solid red");
$("form :text:enabled").css("border", "3px solid red");
$("form :checked").css("border", "3px solid red");
$("form :checkbox:checked").css("border", "3px solid red");