I have done the following code for a list of pics, when the user mouseover the picture an alt is showing up:
I would like to know if there is anyway I can move the mouseover’ed element only and not all of them like i do now.
#{list items:gallery.listPictures(), as:'picture'}
<a class="pic" href="@{Galleries.showPicture(picture.id)}"><img src="@{Application.getPicture(picture.id)}" alt="${picture.name}" />
<span class="alt">${picture.name}</span>
</a>
#{/list}
<script type="text/javascript">
$(function(){
$(".pic").mouseover(function(event){
$(".alt").css({'top': event.pageY, 'left': event.pageX});
});
});
Notice the
$(this). Inside a jQuery functionthiswill access the current element that fired the event.See jQuery selectors and jQuery child-selector and jQuery .find()