This is paragraph 1.
This is paragraph 2.
This is paragraph 3.
This is paragraph 4.
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
function setStyle1() {
$('p:first').css("font-style", "italic");
}
function setStyle2() {
$('p:last').css("font-weight", "bold");
}
function resetStyle() {
$('p:first').css("font-style", "normal");
$('p:last').css("font-weight", "normal");
}
</script>
<style type="text/CSS">
<!--
.code { color: red; }
.back { background-color: yellow; }
-->
</style>
</head>
<body>
<h1>Select the first of a set of elements with p:first</h1>
<div>
<p>This is paragraph 1.</p>
<p>This is paragraph 2.</p>
<p>This is paragraph 3.</p>
<p>This is paragraph 4.</p>
</div>
<form action="">
<input type = "button" value="Style first paragraph" onclick="setStyle1()"></input>
<input type = "button" value="Style last paragraph" onclick="setStyle2()"></input>
<input type = "button" value="Undo Styles" onclick="resetStyle()"></input>
</form>