Jon
Jon
KPCKevin Powell - Community
Created by Jon on 8/28/2023 in #front-end
Best way to achieve this design?
What would be the option for this design? It's tempting to go down the absolute route but is that the best? https://i.imgur.com/kFGU71b.png
8 replies
KPCKevin Powell - Community
Created by Jon on 12/6/2022 in #front-end
Changing value of first loop in a for loop
I'm looping through an array of images and adding them to a carousel. The first image in the carousel needs to have an "active" class, but the rest needs to be without it. Currently my code looks like this
for (let i = 0; i < json.media.length; i++) {
mediaArray += `
<div class="carousel-item active">
<img src="${json.media[i]}" class="d-block w-100" alt="...">
</div>
`


}
for (let i = 0; i < json.media.length; i++) {
mediaArray += `
<div class="carousel-item active">
<img src="${json.media[i]}" class="d-block w-100" alt="...">
</div>
`


}
How do i make the first loop have active and the rest not?
5 replies
KPCKevin Powell - Community
Created by Jon on 10/10/2022 in #front-end
Calling a function with params onclick
I'm trying to call a function with a param. As i have it now the function gets called on load, how can i make it wait for the user to click and still have my param?
deletePostBtn.addEventListener("click", deletePost(baseURL))
deletePostBtn.addEventListener("click", deletePost(baseURL))
5 replies
KPCKevin Powell - Community
Created by Jon on 10/5/2022 in #front-end
Problem with addeventlistener
Could someone explain why this is making the function run before any button has been pressed? Should this not wait until deletePostBtn has been clicked before running deletepost()?
deletePostBtn.addEventListener("click", deletePost())
deletePostBtn.addEventListener("click", deletePost())
9 replies