-
Notifications
You must be signed in to change notification settings - Fork 0
/
my_blog.js
37 lines (31 loc) · 1.19 KB
/
my_blog.js
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
const postsElement = document.getElementById('posts');
document.addEventListener('DOMContentLoaded', function() {
const likeButtons = document.querySelectorAll('.like-button');
likeButtons.forEach(button => {
button.addEventListener('click', function() {
const likesCountSpan = this.nextElementSibling;
let likesCount = parseInt(likesCountSpan.textContent.split(' ')[0]);
likesCount++;
likesCountSpan.textContent = `${likesCount} likes`;
});
});
const posts = document.querySelectorAll('.post');
posts.forEach(post => {
post.addEventListener('click', function() {
window.location.href = 'posts.html';
});
});
const post_ = document.querySelectorAll('.post1');
post_.forEach(post => {
post.addEventListener('click', function() {
window.location.href = 'podcasts.html';
});
});
const homeButtons = document.querySelectorAll('.homepage, .Home');
homeButtons.forEach(button => {
button.addEventListener('click', function(event) {
event.preventDefault();
window.location.href = 'my_blog.html';
});
});
});