How to use jQuery .addClass() to add css .class selector to last HTML <p> element

1 Answer

0 votes
<!doctype html>
<html>
<head>
  <script src="js/jquery/1.11.3/jquery.min.js"></script>
 <style>
  .setcolor {
    color: green;
  }
  </style>
</head>
<body>
 
<p>jQuery</p>
<p>JavaScript</p>
<script>
$( "p" ).last().addClass("setcolor");
</script>
</body>
</html>

 



answered Aug 18, 2016 by avibootz
...