-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSample-2.html
64 lines (64 loc) · 2.01 KB
/
Sample-2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<html>
<head>
<title>Sample2</title>
<script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type ="text/javascript">
</script>
<script type = "text/javascript" >
$(function() {
console.log($('ul.myList > li > a[href^=http://]'));
//
console.log($('div[title^=fo]'))
//match any element
console.log($('div[title*=o]'))
//match all the element a tag in li
console.log($('li:has(a)'));
console.log($('ul:has(a)'));
console.log($('ul + div'));
console.log($('a[href$=s]'));
console.log($('a:only-child'));
console.log($('a:first'));
console.log($('a:last'));
console.log($('a:last-child'));
console.log($('a:first-child'));
console.log($('li:nth-child(1)'));
//it start from 3rd tag and displat every 2nd tag
console.log($('a:nth-child(2n + 3)'));
console.log($('a:odd'));
console.log($('a:eq(5)'))
console.log($('a:gt(5)'))
$("<div class='foo'>I have foo!</div><div>I don't</div>").filter(".foo").click(function() {
alert("I'm foo!");
}).end().appendTo("#fo");
var n = $('a[id]').add('a').index($('div#fo a')[1]);
console.log(n);
console.log($('div#form').add('<h4>Hi!</h4>'));
});
</script>
</head>
<body>
<ul class="myList">
<li><a href="http://jquery.com">jQuery supports</a>
<ul>
<li><a href="css">CSS1</a></li>
<li><a href="cs">CSS2</a></li>
<li><a href="css">CSS3</a></li>
<li>Basic XPath</li>
</ul>
</li>
<li>jQuery also supports
<ul>
<a href = "#">click me</a>
<li>Custom selectors</li>
<li>Form selectors</li>
</ul>
</li>
</ul>
<div title = "form" id = "fo">
<a href = "#">bbbb</a>
<a href = "#">aaaa</a>
<a href = "#">cccc</a>
<a href = "#">dddd</a>
<a href = "#">ffff</a>
</div>
<body>
</html>