admin管理员组文章数量:1391991
I am using lytebox for my image gallery. It works great except when a user hovers on images, there will be texts with html
tags shown on the browser.
ex:
<h1>This is the first image </h1>
<p>The image desc<p>
I need the title
attribute for my image gallery but don't want it to show when the user hovesr the image. Is that possible? Thanks for the help.
I am using lytebox for my image gallery. It works great except when a user hovers on images, there will be texts with html
tags shown on the browser.
ex:
<h1>This is the first image </h1>
<p>The image desc<p>
I need the title
attribute for my image gallery but don't want it to show when the user hovesr the image. Is that possible? Thanks for the help.
- can u post it on jsfiddle or demo on your site? – Dips Commented Jun 5, 2012 at 1:57
- you can hide the the hover effect using css but for title you might need to change jquery. – Dips Commented Jun 5, 2012 at 1:59
- why don't you just use alt tag instead of title then? – Nikola Bogdanović Commented Jun 5, 2012 at 2:00
3 Answers
Reset to default 4var imgTitle;
$("img").hover(function(){
imgTitle = $(this).attr("title");
$(this).removeAttr("title");
}, function(){
$(this).attr("title", imgTitle);
});
I think you'd have to do something like:
$('#slideshow img').hover(function() {
$(this).data('title', $(this).attr('title'));
$(this).attr('title', '');
}, function() {
$(this).attr('title', $(this).data('title'));
});
Demo: http://jsfiddle/lucuma/cX5MD/
You won't see the title on the img's but if you inspect them you'll see they are still there.
You could also use jQuery removeAttr
and attr
instead of setting it to empty string.
Very simple like this
$('img').removeAttr('title');
本文标签: javascriptRemove image title when mouse hover on the imageStack Overflow
版权声明:本文标题:javascript - Remove image title when mouse hover on the image - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744663818a2618409.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论