My like button was previously made using dom and my video section content was made via static html at first, the function was adding like once, removing it when user presses it again ( was working )
I created a function to render my video skeleton page in jquery which appends video info from an array now everything works except for my like button.
Likebutton code:
let thumbsUp = false;
$(".fixButtonsCounter").on("click", () => {
console.log("Farhan")
if (!thumbsUp) {
thumbsUp = true;
$(".icon55").html() = `<i class="fas fa-thumbs-up"></i>`; //.innerHTML -->html()
count.text()++; //textContent -->.text()
} else {
thumbsUp = false;
$(".icon55").html() = `<i class="far fa-thumbs-up"></i>`;
$(".count55").text()--;
}
});
Video Render code:
$(".batata4").on("click", function () { // TedXTalks RENDER
console.log("CSS clicked")
TedTalks.forEach((item, i) => {
$(".video-section").append(`
<article class ="video-container">
<a href="#" class="thumbnail">
<iframe width="560" height="315" src="${item.src}" title="YouTube video player" frameborder="0" allow="accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</a>
<div class="video-bottom-section">
<a href="#">
<img class="channel-icon" src="http:///unsplash.it/36/36?gravity=center" alt="Your Channel" />
</a>
<div class="video-details">
<a href="#" class="video-channel-name">${item.vcn}</a>
<a href="#" class="video-title"> ${item.vt} </a>
<button class="fixButtons"onclick="showVideoOne()">View</button>
<button class="fixButtonsCounter">
<span class="icon55" id="icon"><i class="far fa-thumbs-up"></i></span>
<span class ="count55" id="count">0</span>
</button>
</div>
</div>
</article> `);
});
});
Array code:
let TedTalks = [{src:"https://www.youtube.com/embed/JsC9ZHi79jo",vcn:"TEDx Talks",vt:"How to triple your memory by using this trick | Ricardo Lieuw On | TEDxHaarlem"},{src:"https://www.youtube.com/embed/esPRsT-lmw8",vcn:"TEDx Talks",vt:"The most important lesson from 83,000 brain scans | Daniel Amen | TEDxOrangeCoast"},{src:"https://www.youtube.com/embed/-KysuBl2m_w",vcn:"TEDx Talks",vt:"Choices that can Change your Life | Caroline Myss | TEDxFindhornSalon"}]
Can you please tell me where my problem is so that I can fix it, thank you!