I am having some trouble with css modules in react I dont know how to use react modules in a dynamic way I want to be able to display the classes showing the value that corresponds to the element in state . is this even possible or should I approach the problem differently I want to be to do some
Tag: css
How to get the filename from the full path and store in an object property in Javascript?
My initial problem was to store only the filename from the full path on an object and I did find the answers to that online but I had problem storing the same in a property of an object. Here is a piece of code that I have written. Hopefully my problem would be clear. This whole code is inside a
Javascript onclick script is changing the class on an element not containing specified class
I have a small piece of javascript to add a css class to a button element that already contains two classes under the top level of a menu when clicking outside that menu. I understood that writing the two classes as below should select only elements that have both classes. It does what has been asked on the e…
JavaScript shopping cart not functioning correctly
I tried coding a webpage with a functional shopping cart, where you can add items, and see the total money. There’s obviously something wrong with my JS, I just don’t know what it is since I’m new to JS. You’re supposed to be able to add items to the cart and see the total amount… I’m …
Bootstrap Studio – The style property of my “ element is not changing during my JS function
I am using Bootstrap (in Bootstrap Studio) and plain JavaScript. I have colored the background of my <div> element by setting the CSS color to the default color. Now, I am trying to change that CSS color by setting a new value when a new tab is selected. The goal is to change the background color of tab…
How do you apply a class’s style with setAttribute inside a class that extends HTMLElement?
I have a class that I add an element with a class name that should make the text white which I have defined in my CSS’s style, but it does not. The text remains black. How am I supposed to achieve this other than setting the element’s CSS manually? Answer You have added h5 element to the shadow do…
window scroll in not working with if else if
I’m using the scroll function, but the code in my else if blocks do not appear to be executing. I’m trying to hide one div and show another, once the user scrolls past a certain point. Here’s my code – what am I doing wrong? Answer The problem is the else if conditions. The else if is …
Displaying and hiding of loader div not working synchronously as intended in Javascript
I want a loader element to show while my Sudoku solver function is running and hide upon completion. However, what happens in practice is that the loader never shows itself (or shows and hides almost instantly) even while the solver function is running. The timer for showing performance seems to be working an…
Image max height and max width while preserving aspect ratio
Is it possible to give max-height and max-width to an image while preserving aspect ratio without using js? For example, I want an image to be with a height of 38px and the width auto. If the width is higher than 200px, I want the width to be 200px and the height auto. If it’s not possible without js, d…
Javascript & HTML – tokens not appearing on connect four board
I’m creating a connect four game using javascript, html, and css, and I’m having trouble with my refreshGrid() function in game.js. Running my html file is currently just an empty board, and this function is supposed to make it so that when the user clicks on an empty space on the board, a chip ap…