jQuery 抄袭笔记(13) : Parent()
15 Oct 2011摘自w3school:
parent() 获得当前匹配元素集合中每个元素的父元素,使用选择器进行筛选是可选的。
parents() 获得当前匹配元素集合中每个元素的祖先元素,使用选择器进行筛选是可选的。
如果给定一个表示 DOM 元素集合的 jQuery 对象,.parent() 方法允许我们在 DOM 树中搜索这些元素的父元素,并用匹配元素构造一个新的 jQuery 对象。.parents()和 .parent() 方法类似,不同的是后者沿 DOM 树向上遍历单一层级。
02 <html xmlns=“http://www.w3.org/1999/xhtml”>
03 </span>
04 <meta http-equiv=“Content-Type” content=“text/html; charset=gb2312″ />
05
06 <script type=“text/javascript” src=“jquery-1.1.3.pack.js”></script>
07 <script type=“text/javascript”>
08 $(document).ready(function(){
09 $(“a”).hover(function(){
10 $(this).parent().addClass(“highlight”);}
11 ,function(){
12 $(this).parent().removeClass(“highlight”);}
13 );
14 });
15 </script>
16
17 .highlight{
18 background:#000;
19 color:#fff;
20 border:1px solid;
21 }
22
23 </head>
24 </span>
25
</span>Keyshia Cole – Fallin Out </span></span>
26 Been sitting thinking about you and I am
27 wondering why were not getting along
28 <a href=” “>So frustrated cause</a>
29 what we had was a
30 happy home
31 I don’t know what the
32 situation is
33 But I could tell in the way we kiss
34 we don’t talk no more
35 it feels better when
36 I'm alone
37
38 Sometimes I feel like there’s no getting through to you
39 Like you don’t appreciate all that I do
40 You gotta show me that you want me to stay
41 Don’t turn and walk away
42
43 Baby I'm slowly falling out of
44 love with you I don’t know what to do
45 How did we end up here this way
46 what are we gonna do
47 </pre>
48 </p></p>
49
50
51 </span>
52 Keyshia Cole – Fallin Out
53 Been sitting thinking about you and I am
54 wondering why were not getting along
55 <a href=” “>So frustrated cause</a>
56 what we had was a
57 happy home
58 I don’t know what the
59 situation is
60 But I could tell in the way we kiss
61 we don’t talk no more
62 it feels better when
63 I'm alone
64
65 Sometimes I feel like there’s no getting through to you
66 Like you don’t appreciate all that I do
67 You gotta show me that you want me to stay
68 Don’t turn and walk away
69
70 Baby I'm slowly falling out of
71 love with you I don’t know what to do
72 How did we end up here this way
73 what are we gonna do
74 </pre>
75 </p>
76
77 </body>
78 </html>
</div>
下载源码
转载请注明:[于哲的博客][1] » [jQuery 抄袭笔记(13) : Parent()][2]
[1]: http://lazynight.me
[2]: http://lazynight.me/515.html