Внутри <p> не может быть <div>, учите HTML!
Есть способ сделать быстрее:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<title>…</title>
</head>
<body>
<style type="text/css">
#main.green .colored {
background-color: #9f3;
}
</style>
<button id="but">Click Me</button>
<div id="main">
<div class="colored">One</div>
…
<div class="colored">Two</div>
…
<div class="colored">Three</div>
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$("#but").click(function () {
$("#main").addClass("green");
});
</script>
</body>
</html>
Или вообще без jQuery:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<title>…</title>
</head>
<body>
<style type="text/css">
#main.green .colored {
background-color: #9f3;
}
</style>
<button id="but">Click Me</button>
<div id="main">
<div class="colored">One</div>
…
<div class="colored">Two</div>
…
<div class="colored">Three</div>
</div>
<script type="text/javascript">
document.getElementById("but").onclick = function () {
document.getElementById("main").className = "green";
};
</script>
</body>
</html>