Kevin Powell - Community

KPC

Kevin Powell - Community

A friendly place for developers to meet other devs, ask questions, get help, and just have a good time 🙂.

Join

front-end

resources

back-end

ui-ux

os-and-tools

help

why does innerHTML return number as NaN?

here's my code: ```const bill = document.getElementById('bill'); const billAmount = parseFloat(bill.value); const numOfPeople = document.getElementById('numberOfPeople');...

problem fetching APi

Browser returns invalid API key. Anyone know how to fix this?

how do i loop over buttons that have the same class but are to do different things?

in a case like the image, how do i assign the different calculation algos to each button but with much lesser code, rather than writing out different codes for each button? ```const tipButtons = document.querySelectorAll('.select_btn'); tipButtons.forEach(elem => { console.log("button clicked"); ...

Loading css from js causes the content to jump?

I have customized bootstrap 5 and I need to support rtl I am using rtlcss to generate the .rtl.css file which is working but using the <link> to include both css files was causing problems, so I used javascript to detect the dir in html tag and then decided which css file to load using document.head.appendChild(linkElement) where linkElement conttains the path to the .css or .rtl.css file, but this is causing in the beginning the content to jump as if the styles are applying after the page has already loaded how to fix this?...

Need help in general with css

im having issues where i set display to flex in parent and used alignitems & justify content to center but in child property its suggesting display as block. i watched few tutorials in theory its looks easy but when i try to do something im facing issues like this https://cdn.discordapp.com/attachments/448294302053957632/1054276667780104272/image.png...

Using the dialog element for an off canvas menu

👋 everyone! Do you think using the <dialog> element for creating an off canvas menu is a smart move? I wanted to take advantage of all the built-in functions that come with <dialog>, like esc key, focus, backdrop etc....

regExp Question

in the [-\w] what does the - mean is it considered as a code or it's just a letter...

async await in loops

I have this code, but I don't understand why this all gets printed right after each other, where I would expect that the rl.question call gives me a prompt in terminal which waits for input. useful information is that before this piece is run, there is another part that also uses the rl.question where it actually waits for that user input in the terminal (and then uses that as expected in the callback) ```typescript for (let round = 1; round <= this.GAME_ROUNDS; round++) { for (let player of this.players) {...

slide show

https://aarzookhurana.com/ how can I achieve this slide show with pause, resume, next, previous buttons in vanilla js...

Is storing large objects inside svelte store a bad idea?

I have a large object, would it make more sense to store it in svelte store or since its large in the app.svelte variable instead

JS Ignoring my if condition

I'm trying to add the value of a selected radio button to a span after clicking a submit button. Here's what my HTML looks like ```...

Nested comments

hello guys im stuck with a problem . Im building a nested comments system (with replies and comments) but i can only delete comments and not replies . I dont know how to delete both replies and comments in one function btw im using react and redux toolkit...

My icon doesn't appear

i've been adding font-awesome cdn-s but still doesn't work idk why

offsetTop not always correct when offsetParent is body

So according to the specs, offsetTop is "the distance between the outer border of the current element relative to the inner border of the top of the offsetParent." And the offsetParent is "the element which is the closest (nearest in the containment hierarchy) positioned ancestor element," but "if there is no positioned ancestor element, the body is returned." However, I've noticed that in the 3 major browsers / rendering engines, if an element's offsetParent is body, and body is static, then the following properties are ignored: body margin and border, and <html> margin, border, or padding. That means that the element's offset top and left are actually relative to the viewport, not the body....

React (Vite) importing your own fonts

I've been trying to get my fonts to work in my project for a few days now but I keep getting errors. Even though they work locally, I keep getting these errors: ``` downloadable font: download failed (font-family: "Inter" style:normal weight:400 stretch:100 src index:1): status=2147746065 source: http://localhost:5173/fonts/Inter-VariableFont_slnt_wght.ttf...

Contrast Issue wont go away

The dev tools CSS Overview says I have a contrast issue and it never goes away no matter what I choose. Please check over this pen https://codepen.io/MD-2016/pen/WNKejLj...

How can i combine these arrays elements together gsap, scroll trigger, vanilla js

Hello I am working on combining these elements together. I am not are how I can just scroll them together based on texts element height that I have ? How do I combine those arrays of elements ```js...

is there a way to toggle multiple CSS classes in one statement?

i have a class called active that i would like to add to all my side-bar_menu-text classes on the click of a button, but it only adds this class to the first element. my code: const collapseMenuBtn = document.getElementById('collapse-menu');...

[Blackjack game] [code review] [feedback] Game doesnt end even after player or dealer goes past 21.

Hey all, i think i went wrong somewhere and the blackjack game keeps on going even after player /dealer reached 21 or above. i couldnt find where the issue is. can someone help me with the code? thankyou. https://scrimba.com/scrim/cG82vWCR...

Not able to centre Paragraph inside a Div

Here is my code: https://codepen.io/anurag1989/pen/GRGVjXa The main problem is the 'btn' class. I am not able to centre it inside the btn class. Tried making the display property of 'p element' as inline-block but still not working. On opening the inspection tool, I see that the text area of btn class is increasing (leaving white space) which is making the text inside it to look off the centre. Is there any way out for this?...