WordPress)非跨页悬浮显示你回复之人的评论内容
召唤 @snowxh …我写好了!
标题很绕很绕,不过有图有真相:
真相图截自@冰剑的博客。
这种效果让我们只要轻晃鼠标就能轻松地看出某某人在回复@blabla的哪句话。JS代码如下:
<script type="text/javascript">
var id = /^#comment-/;
var at = /^@/;
$('#thecomments li p a').each(function() {
if ($(this).attr('href').match(id) && $(this).text().match(at)) {
$(this).addClass('atreply')
}
});
$('.atreply').hover(function() {
$($(this).attr('href')).clone().hide().insertAfter($(this).parents('li')).attr('id', '').addClass('tip').fadeIn(200)
},
function() {
$('.tip').animate({
opacity: "hide",
top: "+=100px"
},
400,
function() {
$(this).remove()
})
});
$('.atreply').mousemove(function(e) {
$('.tip').css({
left: (e.clientX + 18),
top: (e.pageY + 18)
})
});
</script>
然后是CSS…
#thecomments .tip {
position:absolute;
width:300px;
border-radius:8px;
-moz-border-radius:8px;
-webkit-border-radius:8px;
-moz-box-shadow:0 4px 18px #c8c8c8;
-webkit-box-shadow:0 4px 18px #c8c8c8;
z-index:999;
background-color:#fff;
}
正如@winy所说,这段代码没有ajax过程,不能显示跨页的评论。
引用@m12的话,就是:
—————————引用分割线—————————
为什么不能跨页显示?
因为其工作原理是, 当鼠标移动到 @{username} 时在本页找到对应的评论, 并插入到评论列表中, 以绝对位置的方式显示出来. 如果评论不在本页, 找不到对象, 当然就没有后面的处理了.
—————————引用分割线结束—————————
想学更多?
下面是跃迁地址:
跨页悬浮显示 @ 评论 (代码篇)
完毕!<( ̄︶ ̄)>
下一篇:行为艺术(续)被刷读者墙…


Firefox 3.6.8
Windows XP
2010/08/30 9:15 上午 on 1博主一直在研究怎么美化博客啊
Google Chrome 6.0.490.0
Windows XP
2010/08/15 2:07 下午 on 1我表示我是来围观的
Google Chrome 6.0.495.0
Windows XP
2010/08/17 3:42 下午 on 2@yetone 舌苔
Google Chrome 6.0.472.33
Windows XP
2010/08/15 6:57 上午 on 1
Google Chrome 5.0.375.126
Windows 7
2010/08/15 7:43 上午 on 2@阿邙 效果惨不忍睹,所有节点都克隆了!放一边先…
Maxthon 3.0
Windows XP
2010/11/16 1:41 下午 on 3@MOPVHS 终于碰到闯说中的匿名列
Firefox 3.6.8
Windows Vista
2010/08/15 3:07 上午 on 1我发现我最近的出镜率好高
我表示灰常开心 ( ̄︶ ̄)
Google Chrome 5.0.375.126
Windows 7
2010/08/15 7:46 上午 on 2@snowxh (# ̄▽ ̄#) 开心就好~~~3:04还在偷笑的你现在一定睡得很香鸟…
Firefox 3.6.8
Windows Vista
2010/08/15 12:48 下午 on 3@MOPVHS ╮( ̄▽ ̄”)╭还好啦啦啦啦
Google Chrome 5.0.375.126
Windows 7
2010/08/15 2:23 上午 on 1好炫的博客啊
大爱
Google Chrome 5.0.375.126
Windows 7
2010/08/15 7:47 上午 on 2@laowi ╰( ̄▽ ̄)╭真的真的?
Google Chrome 5.0.375.126
Windows 7
2010/08/15 11:48 上午 on 3@MOPVHS 动来动去的 好有快感哟
GreenBrowser
Windows XP
2010/08/15 2:13 上午 on 1我表示右上角几个图标 吓到我了..
Google Chrome 5.0.375.126
Windows 7
2010/08/15 7:41 上午 on 2@mice 野人!2:13分出没,当然会被吓到了!
Firefox 3.6.8
Windows 7
2010/08/15 12:11 上午 on 1又刷了一遍看到效果了~~~可以mark以后热闹起来再加~~~~
不过我没有加@的前缀儿……= =
Firefox 3.6.8
Windows XP
2010/08/14 10:50 下午 on 1不明真相
Google Chrome 5.0.375.126
Windows 7
2010/08/14 11:40 下午 on 2@流年
其实这篇日志现在才真正写完~~~
Google Chrome 6.0.486.0
Windows XP
2010/08/14 11:48 下午 on 3@MOPVHS 这下明白了
Firefox 3.6.6
Windows 7
2010/08/14 10:06 下午 on 1说实话,我没看明白题目。
不过刷墙什么的最喜欢了~~~
Google Chrome 5.0.375.126
Windows 7
2010/08/14 10:19 下午 on 2震精…刷墙!
Firefox 4.0b3
Windows 7
2010/08/14 8:24 下午 on 1你们的变量咋这马古怪啊。。/^#comment-/
Google Chrome 5.0.375.126
Windows 7
2010/08/14 10:18 下午 on 2这貌似为正则表达式..
Firefox 3.6.4
Windows 7
2010/08/14 5:18 下午 on 1你教程也太。。。太简单了吧。。。
Google Chrome 5.0.375.126
Windows 7
2010/08/15 7:46 上午 on 2@冰剑
那只是底稿!现在才是完整版…
Internet Explorer 6.0
Windows XP
2010/08/15 5:51 下午 on 3报告,IE6下JS出错。。
你侵犯了我博客的肖像权,我要去告你。。
Google Chrome 5.0.375.126
Windows 7
2010/08/15 7:36 下午 on 4@冰剑 thanks,其实IE7下js都会卡住…
那啥,是不是要我把你的头像打个马赛克什么的…
Firefox 3.6.4
Windows 7
2010/08/15 11:41 下午 on 5@MOPVHS 不是,我只是想说赔偿一点损失费就可以了。
Google Chrome 5.0.375.126
Windows 7
2010/08/15 11:55 下午 on 6@冰剑 左顾右盼无视你…
Firefox 3.6.4
Windows 7
2010/08/15 11:56 下午 on 7@MOPVHS 哎,赚不到钱了。。
Google Chrome 6.0.466.0
Windows 7
2010/08/14 4:02 下午 on 1不能跨页的吧?没有ajax过程,是本页的
Google Chrome 5.0.375.126
Windows 7
2010/08/14 4:14 下午 on 2@winy 对啊!默默改成“非跨页”…
因为刚刚在做伪分页效果…通过元素的隐现假装分页…
Firefox 3.6.4
Windows 7
2010/08/14 5:19 下午 on 3@MOPVHS 话说,这个效果有点惨不忍睹。。
Google Chrome 5.0.375.126
Windows XP
2010/08/14 3:42 下午 on 1忍不住再来发一个,你又装修了,这的多少钱啊~~~
Firefox 3.6.8
Windows Vista
2010/08/14 3:36 下午 on 1差点忘了还要改成@blabla格式
恩 我果然看我那个回复不爽很久了
Google Chrome 5.0.375.126
Windows 7
2010/08/14 4:07 下午 on 2@snowxh
Firefox 3.6.8
Windows Vista
2010/08/14 3:34 下午 on 1耶- -
啦啦啦
Google Chrome 5.0.375.126
Windows 7
2010/08/15 10:42 上午 on 2@snowxh 沙发回复测试!