-
Notifications
You must be signed in to change notification settings - Fork 35
/
css.link-types.html
131 lines (116 loc) · 4.11 KB
/
css.link-types.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Селекторы по CSS3 атрибутам</title>
<link rel="profile" href="https://gmpg.org/xfn/11"/>
<link rel="shortcut icon" href="https://anton.shevchuk.name/favicon.ico"/>
<link rel="stylesheet" href="css/styles.css"/>
<style>
a {
color: #333399;
}
a:hover {
text-decoration: none;
}
a.pdf {
background: url(images/file-red.gif) no-repeat 2px;
padding-left: 16px;
}
a.zip {
background: url(images/file-orange.gif) no-repeat 2px;
padding-left: 16px;
}
a.png {
background: url(images/file-blue.gif) no-repeat 2px;
padding-left: 16px;
}
a.internal:before {
content: "🔗";
}
a.anchor:before {
content: "⚓️";
}
a.external {
background: url(images/window.gif) no-repeat 2px;
padding-left: 16px;
}
</style>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.color.js"></script>
<script type="text/javascript" src="js/code.js"></script>
<script type="text/javascript">
$(function () {
// $('button').click(function () {
// let code = $(this).prev().text()
// if (code) {
// let els = eval(code)
// els
// .stop(true, true)
// .animate({ 'background-color': '#ff5' }, 500)
// .delay(100)
// .animate({ 'background-color': '#fff' }, 500)
// }
//
// })
})
</script>
<script type="text/javascript">
$(function () {
$('main a[href$=pdf]').addClass('pdf')
$('main a[href$=zip]').addClass('zip')
$('main a[href$=png]').addClass('png')
$('main a[href^=\\/]').addClass('internal')
$('main a[href^=\\#]').addClass('anchor')
$('main a[href^=https\\:\\/\\/]').addClass('external')
.attr({ target: '_blank' })
/*
$("a:not(a[href*=anton.shevchuk.name])") //.not("[href^=#]")
.addClass("external")
.attr({ target: "_blank" });
*/
})
</script>
</head>
<body>
<header>
<h1>Селекторы по CSS атрибутам</h1>
<h2>Пример с определением расширения файла</h2>
</header>
<main id="content">
<article>
<h3 id="anchor">Ссылки</h3>
<p><a href="?jquery.pdf">PDF file</a> (jquery.pdf)</p>
<p><a href="?jquery.png">PNG file</a> (jquery.png)</p>
<p><a href="?jquery.zip">Zip file</a> (jquery.zip)</p>
<p><a href="#anchor">Anchor link</a> (#anchor)</p>
<p><a href="/index.html">Internal link</a> (/index.html)</p>
<p><a href="https://anton.shevchuk.name/">External link</a> (https://anton.shevchuk.name)</p>
</article>
</main>
<footer>
© <a href="https://anton.shevchuk.name/jquery-book/">jQuery for beginners</a>
</footer>
<aside>
<nav>
<a href="css.selectors.html" title="go prev" rel="prev">Prev</a>
<a href="index.html" title="back to Index" rel="index">Index</a>
<a href="benchmark.html" title="go next" rel="next">Next</a>
</nav>
<hr/>
<code contenteditable="true"><em>// highlight elements</em>
$(<span>"a[href]"</span>)</code>
<button data-highlight type="button">Run Code</button>
<code contenteditable="true"><em>// highlight document anchors</em>
$(<span>"a[href^=\\#]"</span>)</code>
<button data-highlight type="button">Run Code</button>
<code contenteditable="true"><em>// highlight internal links</em>
$(<span>"a[href^=\\/]"</span>)</code>
<button data-highlight type="button">Run Code</button>
<code contenteditable="true"><em>// highlight external links</em>
$(<span>"a[href^=https\\:\\/\\/]"</span>)</code>
<button data-highlight type="button">Run Code</button>
</aside>
</body>
</html>