问题
I have a gallery of my paintings at www.unlicensedeyesurgery.com which uses the famous Lightbox code. There is one problem with it: the Lightbox code uses the rel
attribute of the anchor tag to display the description of the image in the pop-up "window." However, this somehow overrides the images' alt
property and shows the ugly, HTML-code description in the mouse tooltip. Is there a way to disable to tooltip altogether—perhaps using JS?
Code Example:
<a href="#" rel="<em>lightbox html<span>styled</span> text in here<em>">
<img src="photo.jpg" alt="this is overwritten" />
</a>
回答1:
Your title overrided by <a title="....">
as you have here image set it's title to alt content
you can do it with javascript:
window.onload=function() {
var images=document.getElementsByTagName('img');
for (var i in images) {
images[i].title=images[i].alt ;delete(images[i].alt);
}
};
回答2:
The problem is the anchors rel is getting precedence over the images alt tag in the tooltip.
The solution is to add a title: title="photo title"
to all your img tags and browsers will show that instead of the anchor's rel.
来源:https://stackoverflow.com/questions/13794891/trying-to-remove-pesky-alt-text-from-lightbox-gallery