jQuery: Insert some HTML after all paragraphs

jQuery Fundamental - I : Exercise-8

Using jQuery insert some HTML after all paragraphs.

Sample solution :

HTML Code :

<!DOCTYPE html>
  <script src="https://code.jquery.com/jquery-git.js"></script>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Using jQuery insert a paragraph after all paragraphs.</title>
  <style type="text/css">
  button {
  display: block;
  margin: 20px 0 0 0;
  }   </style>
  <p>jQuery Exercises</p>
  <button id="button1">Click to see the effect</button>

CSS Code:

$( "p" ).after( "<b><i>With solution.</i></b>" );

JavaScript Code :

$( "p" ).after( "<b><i>With solution.</i></b>" );

Used Methods :

  • .after() : Insert content, specified by the parameter, after each element in the set of matched elements.

See the Pen jquery-fundamental-exercise-8 by w3resource (@w3resource) on CodePen.

Contribute your code and comments through Disqus.

Previous: Using jQuery add a new class to an element that already has a class.
Next: Using jQuery insert a DOM element after all paragraphs.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.

Share this Tutorial / Exercise on : Facebook and Twitter