Q:

Using jQuery add the class " w3r_font_color " to the last paragraph element

0

Using jQuery add the class " w3r_font_color " to the last paragraph element.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

HTML Code :

<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-git.js"></script>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
   <title>Add a specified class to the matched elements.</title>
   </head>
   <body>
   <p>PHP</p>
   <p>Java</p>
   <p>Python</p>
 </body>
</html>

CSS Code:

p {
    margin: 8px;
    font-size: 16px;
  }
  .w3r_font_color{
    color: red;
  }
  .w3r_background {
    background: yellow;
  }

JavaScript Code :

$( "p" ).last().addClass( "w3r_font_color" );

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now