forked from barryclark/jekyll-now
-
Notifications
You must be signed in to change notification settings - Fork 2
/
jquery.html
59 lines (54 loc) · 1.39 KB
/
jquery.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
{% if page.jquery %}
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script type="text/javascript">
function toggle(obj) {
var src = obj.attr("src");
if (src.endsWith(".png")) {
obj.attr("src", src.replace(".png", ".gif"));
} else {
obj.attr("src", src.replace(".gif", ".png"));
}
}
function start(obj) {
var src = obj.attr("src");
obj.attr("src", src.replace(".png", ".gif"));
}
function stop(obj) {
var src = obj.attr("src");
obj.attr("src", src.replace(".gif", ".png"));
}
$(document).ready(function () {
$(".img-animate").each(function () {
$(this).on("mouseenter", function () {
start($(this));
});
$(this).on("mouseleave", function () {
stop($(this));
});
$(this).on("touchstart", function () {
toggle($(this));
});
});
});
$(document).ready(function () {
$(".img-swap").each(function () {
var src = $(this).attr("src");
$(this).hover(
function () {
$(this).attr("src", src.replace("jpg", "png"));
},
function () {
$(this).attr("src", src.replace("png", "jpg"));
}
);
});
});
$(function () {
const includes = $("[data-include]");
$.each(includes, function () {
const file = $(this).data("include");
$(this).load(file);
});
});
</script>
{% endif %}