jqueryimagealtcaptions

Jquery - Show Image ALT tag in seperate div on hover


I have a gallery of images that i have set up and when a user hovers over one I wan't it to show the title in a separate div. Ive tried the below code but to no avail. I'm not great at jquery so could someone please correct me?

Div's

galleryimages - Where the thumbnails (to be hovered) are kept

gallerydescription - Where the Title tag from the image is to be displayed.

I would like it also on mouse out that it would clear the description DIV.

<script type="text/javascript">
     $(document).ready(function(){
        $("img.galleryimages").hover(
           function () {
          ("#gallerydescription").html( $(this).attr("alt") );
           }, 
           function () {
              ("#gallerydescription").html("");
           }
        );
     });
</script>

Thanks


Solution

  • ("#gallerydescription").html( $(this).attr("alt") );
    

    should be:

    $("#gallerydescription").html( $(this).attr("alt") );
    

    Note the '$' at the beginning of the line.