-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
45 lines (34 loc) · 840 Bytes
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>vanilla-dom-selector</title>
<style></style>
<script>
(function() {
'use strict';
var $ = document.querySelectorAll.bind(document);
NodeList.prototype.each = HTMLCollection.prototype.each = Array.prototype.forEach;
NodeList.prototype.on = function(a, b) {
return this.each(function(c) {
c.addEventListener(a, b, false);
});
};
window.onload = function() {
$('button.btn2').on('click', function() {
alert(this.textContent);
this.style.cssText = 'background-color: red';
});
$('button').each(function(el) {
el.style.cssText = 'background-color: yellow';
});
};
})();
</script>
</head>
<body>
<button class="btn1">button 1</button>
<button class="btn2">button 2 (click)</button>
<button class="btn3">button 3</button>
</body>
</html>