Home > Technology > 让@someone也实现平滑移动

让@someone也实现平滑移动

上一篇讲到了页面页内的平滑移动.这里就要用到.这里要复习一下addClass和attr..根据前面讲到的内容.我们在此应用一下.addClass就不多说了.前面也举了例子.

关于attr(name).

取得第一个匹配元素的属性值.通过这个方法可以方便地从第一个匹配元素中获取一个属性的值.如果元素没有相应属性,则返回 undefined
Access a property on the first matched element. This method makes it easy to retrieve a property value from the first matched element. If the element does not have an attribute with such a name, undefined is returned.

为了帮助理解.实例一个:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<html >
<head>
<title>test attr(name)</title>
<script type="text/javascript" src="jquery-1.2.6.min.js"></script>
<script language="javascript">
$().ready(function(){
var D=$("img").attr("src");
alert(D);
});
</script>
</head>
<body>
<img src="philna.jpg" alt="" />
</body>
</html>

通过实例.我们得到了src的值.
以这个inove主题为例.前面说到鼠标悬浮显示了留言内容的’教程’中实现了给特定的含有@和comment的字符链接添加class.代码是这样的:

1
2
3
4
5
6
//match add class
var A=/^#comment-/;
var B=/^@/;
if($('#thecomments .info .content p a').text().match(B) && $('#thecomments .info .content p a').attr('href').match(A)){
$('#thecomments .info .content p').addClass('cool');
};

因此配合前面的滑动js添加如下代码就可以实现了:

1
$('.cool a').click(function(){$($(this).attr("href")).ScrollTo(设定时间-单位毫秒);return false;});
  1. Zoll Dec 25th, 2008 @ 19:58 | #26

    十二点前 来道声节日快乐^^ 顺便后面那个“蛋”也捎带着祝福了!

  2. xiaorsz Dec 25th, 2008 @ 20:20 | #27

    兄弟最近比较忙啊,都没见你人影了!!! :razz:

  3. JoBru Dec 25th, 2008 @ 22:35 | #28

    汗~看了锁密码的就知道享受二人世界去了 :idea:
    Merry Christmas!

  4. yinheli Dec 26th, 2008 @ 19:20 | #29

    @G.Jwoogroo
    哈谢谢.你是?…..囧^^
    @Zoll
    节都过了.呵呵.我就提前祝你新年快乐吧.~
    @xiaorsz
    要考试了.我的网费也到期了.
    @JoBru
    没有啦…给她的生日祝福. :eek:

  5. NetPuter Jan 1st, 2009 @ 18:28 | #30

    么有新文章好顶,回顶这一篇~
    考试加油~Happy 牛 Year..!

  6. yinheli Jan 3rd, 2009 @ 11:53 | #31

    @NetPuter
    牛年?还没有到吧…囧~

  7. wanglaoban Jan 5th, 2009 @ 21:29 | #32

    喜欢你的博客,这里留个名。 :arrow:

  8. yinheli Feb 3rd, 2009 @ 13:36 | #33

    test…

Submitting Comment, Give me a second...
Comment pages 1 2

Leave a comment

Allowed tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">
Trackbacks & Pingbacks ( 0 )
  1. No trackbacks yet.