I'm making a website and have an image in it that activates a Javascript function through onmouseover
using a function
. One of these methods I used in Javascript adds a new tag in a span
with an "X" id on which this image is, except that the method instead of only creating the tag, creates the tag each time the mouse passes over the image.
I need this method to only create the tag once when the mouse passes over the image.
Below the image html:
<span id="ex1" >
<img width="794px" height="593px" src="images/crateria.png" style="margin:0;" onmouseover="javascript:mostra();" alt="Crateria" />
</span>
Below the Javascript I used to add the tag, in this case the tag <map>
:
function mostra(){
var para = document.createElement("map");
para.setAttribute("name", "crateria-map");
document.getElementById("ex1").appendChild(para);
}