Adjacent insertion of elements in JavaScript

Given an element:

<div id="elem" style="border: 1px solid red;"> <p>text</p> <p>text</p> <p>text</p> </div>

Insert a paragraph with the text '!!!' before it.

Given an element:

<div id="elem" style="border: 1px solid red;"> <p>text</p> <p>text</p> <p>text</p> </div>

Insert a paragraph with the text '!!!' after it.

Given an element:

<div id="elem" style="border: 1px solid red;"> <p>text</p> <p>text</p> <p>text</p> </div>

Insert a paragraph with the text '!!!' at the beginning of it.

Given an element:

<div id="elem" style="border: 1px solid red;"> <p>text</p> <p>text</p> <p>text</p> </div>

Insert a paragraph with the text '!!!' at the end of it.

Adjacent tag insertion

Given an element:

<div id="elem" style="border: 1px solid red;"> <p>text</p> <p>text</p> <p>text</p> </div>

Given an element. Insert the following tag before it:

<div class="www"><p>text</p><p>text</p><input></div>
enru