Q:

Using jQuery add the class "w3r_font_color" and “w3r_background” to the last paragraph element

0

Using jQuery add the class "w3r_font_color" and “w3r_background” 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 two classes 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: blue;
  }
.w3r_background {
    background: orange;
  }

JavaScript Code :

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

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