JQuery实现脚印高亮
<link rel="stylesheet" type="text/css" href="style.css"><script type="text/javascript" src="jquery.js"></script><script type="text/javascript" src="util.js"></script><script type="text/javascript" src="base.js"></script><script type="text/javascript"> $(document).ready(function() { $(".l").click(function() { $.cookie(this.href, 1, {expires: 4}); highlight(); }); highlight(); })</script><table width=960px align=center style="table-layout:fixed"> <tr> <td> <a href="javascript:clear();" target=_self>清除历史</a> </td> </tr></table><table width=960px align=center style="table-layout:fixed"> <tr> <td width=140px valign="top" align="center"> <table id="table" width="100%" cellspacing=0> <tr><td align="center" href="http://www.nmc.gov.cn/weather.html">天气预报</a></td></tr> <tr><td align="center"><a href="http://www.elong.com/flights/">航班查询</a></td></tr> <tr><td align="center"><a href="http://www.chinamobile.com/">中国移动</a></td></tr> <tr><td align="center"><a href="http://www.zset.gov.cn/reference/time.htm">世界时差</a></td></tr> <tr><td align="center"><a href="http://www.ip138.com/">IP地址查询</a></td></tr> </table> <table id="table" width="100%" cellspacing=0> <tr><td align="center" href="http://www.360.cn/">360安全卫士</a></td></tr> <tr><td align="center"><a href="http://ttplayer.qianqian.com/index.html">千千静听</a></td></tr> <tr><td align="center"><a href="http://www.winrar.com.cn/download.htm">WinRAR</a></td></tr> </table> </td> </tr></table>?
JS代码:
function highlight() { var keys = $.cookie.keys(); for(var i = 0; i < keys.length; i++) { if($.cookie(keys[i]) == 1) { $("a[href=" + keys[i] + "]").css({background:"#ffff66"}); } }}function clear() { var keys = $.cookie.keys(); for(var i = 0; i < keys.length; i++) { $.cookie(keys[i], 0, {expires: 0}); window.location.href = window.location.href; }}?
效果图:
?
