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");

Published by

Mark Taylor

Web developer, based in Bourne, Lincolnshire, UK. builder of web applications, ASP.NET, Web Standards HTML, CSS & JavaScript. SQL Server & MySQL DB developer.

Leave a Reply

Your email address will not be published. Required fields are marked *