1<!doctype html>
2<html lang="en">
3<head>
4 <meta charset="utf-8">
5 <title>addClass demo</title>
6 <style>
7 p {
8 margin: 8px;
9 font-size: 16px;
10 }
11 .selected {
12 color: red;
13 }
14 .highlight {
15 background: yellow;
16 }
17 </style>
18 <script src="https://code.jquery.com/jquery-3.4.1.js"></script>
19</head>
20<body>
21
22<p>Hello</p>
23<p>and</p>
24<p>Goodbye</p>
25
26<script>
27$( "p" ).last().addClass( "selected highlight" );
28</script>
29
30</body>
31</html>
32