1
I have a jQuery that I use on a website that I’m doing that applies the zoom effect on an image. Only when I hover the mouse over the image and it zooms in, jQuery creates another IMG tag with the same image by applying a class="zoomImg" to it:
Only I’m wanting to map this image, so I used a Javascript code in which when hovering over this image that is inside a SPAN with an id="Ex1", it creates a MAP tag in this SPAN:
var para = document.createElement('map');
para.setAttribute('name', 'crateria-map');
document.getElementById('ex1').appendChild(para);
mostra = function() { /* Não faz nada */ } ---> este código eu obtive em outra pergunta, pois a função estava fazendo a tag ser criada toda vez que eu passava o mouse na imagem.
Since I’m going to map this image, I need to add a SPAN tag inside this SPAN tag that was created and using the same code I’m not getting:
var sub = document.createElement('area');
sub.setAttribute('class', 'html5lightbox');
document.getElementByName('crateria-map').appendChild(sub);
In the MAP tag I used the id="Ex1" of the span to add the tag, so I thought I’d use the name of the SPAN tag to add the AREA tag, but as I said, it didn’t work, I’m using a "Function shows()" to enable Javascript.
I hope I have been clear and if I am not being, I apologize, because I understand almost nothing of Javascript.
Ever tried to give a
para.appendChild(sub);
and then give the father an append to?– Felipe Avelar
There is no
getElementByName
only plural and gives an array... foreheaddocument.getElementsByName('crateria-map')[0]
– Sergio
Do you have those lines in the same scope? In that case it would be enough
para.appendChild(sub);
instead ofdocument.getElementByName('crateria-map').appendChild(sub);
– Sergio
Felipe, it seems that it worked out your answer Document.getElementsByName('crateria-map')[0] but I will check if everything is all right even.
– Marcelo Lins de Carvalho
Felipe, it worked, thanks for the help, it would be good for you to put this information as an answer so I can mark it, but vlw!
– Marcelo Lins de Carvalho
@Marcelolinsdecarvalho in this your comment referred to my solution with the name "Felipe", I am Sergio. Which of the ideas used?
– Sergio