change order
This commit is contained in:
38
hearts.js
38
hearts.js
@@ -45,25 +45,6 @@ observer.observe(document.body, {
|
|||||||
// Array of hearts characters
|
// Array of hearts characters
|
||||||
const heartSymbols = ['❤️', '💕', '💞', '💓', '💗', '💖'];
|
const heartSymbols = ['❤️', '💕', '💞', '💓', '💗', '💖'];
|
||||||
|
|
||||||
// create hearts objects
|
|
||||||
function createHearts() {
|
|
||||||
const container = document.querySelector('.hearts-container') || document.createElement("div");
|
|
||||||
|
|
||||||
if (!document.querySelector('.hearts-container')) {
|
|
||||||
container.className = "hearts-container";
|
|
||||||
container.setAttribute("aria-hidden", "true");
|
|
||||||
document.body.appendChild(container);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 0; i < 12; i++) {
|
|
||||||
const heartsDiv = document.createElement("div");
|
|
||||||
heartsDiv.className = "heart";
|
|
||||||
heartsDiv.textContent = heartSymbols[i % heartSymbols.length];
|
|
||||||
|
|
||||||
container.appendChild(heartsDiv);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function addRandomSymbols(count) {
|
function addRandomSymbols(count) {
|
||||||
const heartsContainer = document.querySelector('.hearts-container'); // get the hearts container
|
const heartsContainer = document.querySelector('.hearts-container'); // get the hearts container
|
||||||
@@ -97,6 +78,25 @@ function addRandomSymbols(count) {
|
|||||||
console.log('Random hearts symbols added');
|
console.log('Random hearts symbols added');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create hearts objects
|
||||||
|
function createHearts() {
|
||||||
|
const container = document.querySelector('.hearts-container') || document.createElement("div");
|
||||||
|
|
||||||
|
if (!document.querySelector('.hearts-container')) {
|
||||||
|
container.className = "hearts-container";
|
||||||
|
container.setAttribute("aria-hidden", "true");
|
||||||
|
document.body.appendChild(container);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i < 12; i++) {
|
||||||
|
const heartsDiv = document.createElement("div");
|
||||||
|
heartsDiv.className = "heart";
|
||||||
|
heartsDiv.textContent = heartSymbols[i % heartSymbols.length];
|
||||||
|
|
||||||
|
container.appendChild(heartsDiv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// initialize hearts after the DOM is loaded
|
// initialize hearts after the DOM is loaded
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
Reference in New Issue
Block a user