Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions assets/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
*/

const addEventOnElem = function (elem, type, callback) {
if (elem.length > 1) {
// Check if elem is a NodeList or Array
if (elem instanceof NodeList || Array.isArray(elem)) {
for (let i = 0; i < elem.length; i++) {
elem[i].addEventListener(type, callback);
}
} else {
// This handles single elements AND the window object correctly
elem.addEventListener(type, callback);
}
}
Expand Down Expand Up @@ -73,4 +75,4 @@ const accordionAction = document.querySelectorAll("[data-accordion-action]");

const toggleAccordion = function () { this.classList.toggle("active"); }

addEventOnElem(accordionAction, "click", toggleAccordion);
addEventOnElem(accordionAction, "click", toggleAccordion);
6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@

<div class="hero-content">

<p class="hero-subtitle has-before">Wellcome to Our Agency</p>
<p class="hero-subtitle has-before">Welcome to Our Agency</p>

<h1 class="h1 hero-title">Smart Ideas for your Brand are Here</h1>

Expand Down Expand Up @@ -412,7 +412,7 @@ <h3 class="h3 card-title">Customer Strategy</h3>

<data class="card-number" value="04">04</data>

<h3 class="h3 card-title">Best Premimum Image</h3>
<h3 class="h3 card-title">Best Premium Image</h3>

<p class="card-text">
Nullam ullamcorper condimentum urna eu accumsan.
Expand Down Expand Up @@ -833,4 +833,4 @@ <h3 class="h3 card-title">

</body>

</html>
</html>