Search code examples
jquerycsswordpressalt

Getting an alt tag to show up over an img on hover


So I've got it working on a jsfiddle perfectly here:

http://jsfiddle.net/5dxhC/32/

$('img', '.thumb').each(function() {
  $(this).parent().append('<div class="thumbnail-text">' + this.alt + '</div>');
}).bind({
  mouseenter: function() {
    $(this).siblings('.thumbnail-text').show();
  },
  mouseleave: function() {
    $(this).siblings('.thumbnail-text').hide(); 
  }
});

but I can't for the life of me figure out how to get it to work with a wordpress gallery plug-in here:

http://www.adammichaelogden.com/my_work/

I've tried everything I can think of and I just know its probably something very simple that I'm over looking. Any help?


Solution

  • Actually it seems that $ is not accepting. I had run below code in console on your site and it worked:-

    jQuery('img','.all-images').each(function() { 
        jQuery(this).parent().append('<div class="thumbnail-text">' + this.alt + '</div>'); 
    }).bind({ mouseenter: function() { 
        jQuery(this).siblings('.thumbnail-text').show(); 
    }, mouseleave: function() { 
        jQuery(this).siblings('.thumbnail-text').hide(); } 
    });