views:

15

answers:

0

Using Lightbox 2, I am trying to hide the (long) title and alt tool tips that pop up when I hover over an image thumbnail. By default Lightbox 2 uses the title attribute of the thumbnail link to populate the caption. I believe Firefox uses the title attribute and Internet Explorer uses the alt attribute for tool tips.

As a work around to stop the Internet Explorer tool tips I have an empty title attribute

<a href="images/products/bookslg.jpg" rel="lightbox[product]" title="" cap="This is my very long caption"><img src="images/products/bookssm.jpg" alt="This is my alt text"  width="444" height="50" /></a>

Following this I created a custom attribute called 'cap' and modified the lightbox.js to use that for the captions. It works fine, no tool tips in FF or IE. Only problem is 'cap' is not a valid attribute and I get a validation error.

The other solution I think is to use jquery

    <script type="text/javascript">
   $.fn.hideTips = function(){
      // when building a plugin, "this" references the jquery object that the plugin was called on.
      // iterate through each element and return the elements.
      return this.each(function(){
            // save element for referencing later
            var $elem = $(this)
            // save alt and title
            var savealt = $elem.attr('alt');
            var savetitle = $elem.attr('title');
            // on mouseover, remove attributes
            // on mouseout, set attributes
            $elem.hover(function(){
                  $elem.removeAttr('title').removeAttr('alt');
            },function(){
                  $elem.attr({title:savetitle,alt:savealt});
            });
      });
};
</script>

Source

But I couldn't get that to work......

Any help would be much appreciated