nick / aezer [biffy]
KPCKevin Powell - Community
•Created by nick / aezer [biffy] on 8/10/2024 in #front-end
Accessing multiple HTML ID selectors and changing innerHTML of them.
This is part of a more complex code (relating to a multi-tabbed calculator).
What I am ultimately doing is compiling all the IDs that need a formatting adjusting and wanting to utilize a function to make the necessary adjustments (for example adding a $ or a % or decimals, etc), but I was having trouble with it so I condensed it down to bare bones to show for example.
Ironically I thought this would be the easiest for me to do, but all the other code I have written I had a much easier time handling. These IDs hold values in their actual state, which I have being pulled from form data inputs and calculations handled in other functions... but I wanted this to happen last (so to not interfere with the calculations).
I have two examples above the code I'm focused on. I want to utilize an array of all the IDs and select it in the function. Both work on their own, but the code at line 14 -> 17 doesn't work. Can someone tell me why?
In this example code, the expected behavior is both IDs adjusting the innerHTML to say hiho.
The error in the console just leaves me asking "why?" How do I get this to work as expected?
https://jsfiddle.net/cotm2xhs/
14 replies
KPCKevin Powell - Community
•Created by nick / aezer [biffy] on 12/28/2023 in #front-end
How do I shorten this code?
https://jsfiddle.net/sf6zdx9p/1/
From lines 9-32 I have conditions for each index of the li that is clicked to either remove or add an active class to that list item as well as the corresponding review in the container above that matches its index. I am looking to shorten that into less code with a function, but I am not sure how.
7 replies
KPCKevin Powell - Community
•Created by nick / aezer [biffy] on 11/10/2023 in #front-end
Masking divs to a background image of its container?
34 replies