The after method in jQuery

The after method allows you to add text after elements.

Let's look at the following example, let's say we have a paragraph:

html<p>text</p>

Now we write the following Javascript code:

javascript$('p').after('<b>!!!</b>');

After running the code, the paragraph will look like this:

html<p>text</p><b>!!!</b>

It should be noted that all of the above insertion methods - prepend, append, before and after also provide the ability to apply a function to each element in the set.

Let's find all the paragraphs and put their serial number in the set at the end of each one:

html<p>text</p>
<p>text</p>
<p>text</p>
javascript$('p').append(function(index){return index;});
Задание 1

After each h2, insert '<p>?</p>'.

Задание 2

In one chain, before each h2, insert '<p>!</p>', and after h2 - '<p>?</p>'.