dynamicall add p element on mouse click using javascript
<p>I need a code to display some message on every onclick event of a button using JavaScript</p>

<p><code>enter code here</code>   </p>

<pre><code> &lt;!DOCTYPE&gt;
  &lt;html&gt;
     &lt;head&gt;
         &lt;script&gt;
             function addElement() {
 var ni = document.getElementById('myDiv');
 var numi = document.getElementById('theValue');
 var num = (document.getElementById('theValue').value -1)+ 2;
  numi.value = num;
 var newdiv = document.createElement('div');
 var divIdName = 'my'+num+'Div';
 newdiv.setAttribute('id',divIdName);
 newdiv.innerHTML = 'Element Number '+num+' has been added! &lt;a href=\'#\'       onclick=\'removeElement('+divIdName+')\'&gt;Remove the div "'+divIdName+'"&lt;/a&gt;';
 ni.appendChild(newdiv);
 }
        &lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;div id='myDiv'&gt;
            &lt;input type="button" value="click" onclick="addelement()"&gt;
                &lt;p id='theValue'&gt;&lt;/p&gt;
        &lt;/div&gt;
    &lt;/body&gt;
  &lt;/html&gt;
</code></pre>
