Using jQuery add the class "w3r_font_color" and “w3r_background” to the last paragraph element.
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 " );
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
HTML Code :
CSS Code:
JavaScript Code :