Javascript代码
简介
用简单的jquery+CSS创建自定义的a标签title提示,用来代替浏览器默认行为。如图:
Javascript代码
$(function() { <br>$("a[title]").each(function() { <br>var a = $(this); <br>var title = a.attr('title'); <br>if (title == undefined || title == "") return; <br>a.data('title', title) <br>.removeAttr('title') <br>.hover( <br>function () { <br>var offset = a.offset(); <br>$("<div id='\"anchortitlecontainer\"'></div>").appendTo($("body")).html(title).css({ top: offset.top + a.outerHeight() + 10, left: offset.left + a.outerWidth() + 1 }).fadeIn(function () { <br>var pop = $(this); <br>setTimeout(function () { pop.remove(); }, pop.text().length*80); <br>}); <br>}, <br>function() { $("#anchortitlecontainer").remove(); } <br>); <br>}); <br>}); <br>