i am generating multiple span element all of the same id
<span id='myLink'>some text</span>
and using jquery i want to open a div overlay near it using the offset of the span element
but when i call a function it only works for the first span element
$('#myLink').click(function() {
var divOverlay= jQuery('<div id="divOverlay">text on overlay </div>');
var off=$(this).offset();
divOverlay.css(
{
left:(off.left)+'px',
top:(off.top-200)+'px'
});
divOverlay.appendTo(document.body)
});
thanks
is causing the problems, Id’s must be unique.
Use a class instead