JQuery学习(层级)ancestor & descendant

Posted 小兵一枚

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JQuery学习(层级)ancestor & descendant相关的知识,希望对你有一定的参考价值。

 1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
 2 <%
 3     String path = request.getContextPath();
 4     String basePath = request.getScheme() + "://"
 5             + request.getServerName() + ":" + request.getServerPort()
 6             + path + "/";
 7 %>
 8 
 9 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
10 <html>
11 <head>
12 <base href="<%=basePath%>">
13 
14 <title>My JSP \'jquery.jsp\' starting page</title>
15 
16 <meta http-equiv="pragma" content="no-cache">
17 <meta http-equiv="cache-control" content="no-cache">
18 <meta http-equiv="expires" content="0">
19 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
20 <meta http-equiv="description" content="This is my page">
21 <script type="text/javascript" src="/common/easyui/jquery.min.js"></script>
22 <script type="text/javascript">
23     $(document).ready(function(){
24     $("form input").css("background-color","yellow");
25     });
26     
27 </script>
28 
29 </head>
30 <body>
31 <form>
32   <label>Name:</label>
33   <input name="name" />
34   <fieldset>
35       <label>Newsletter:</label>
36       <input name="newsletter" />
37  </fieldset>
38 </form>
39 <input name="none" /> 
40 
41 </body>
42 </html>

            效果图1-1

重点解释:

 $("form input"):即form下所有input
结合JQuery1.4.2API还有:

parent>children:父元素下所有子元素
$("form > input"):form下所有input

prev+next:跟在prev后所有的next元素
$("form+input"):跟在form后的所有input元素

prev ~ siblings:与prev同级的siblings元素
$("form ~ input"):与form同级的input元素

以上是关于JQuery学习(层级)ancestor & descendant的主要内容,如果未能解决你的问题,请参考以下文章

jQuery复习:第二章&第三章

JQuery选择器学习整理(基本选择器,层级选择器,伪类选择器,属性过滤,内容过滤,可见性过滤,范围选择器,排除选择器)

[LeetCode&Python] Problem 235. Lowest Common Ancestor of a Binary Search Tree

Lowest Common Ancestor of a Binary Search Tree & a Binary Tree

LCA/tarjanPOJ1470-Closest Common Ancestors

LeetCode 236. Lowest Common Ancestor of a Binary Tree; 235. Lowest Common Ancestor of a Binary Searc