I’m new to vanilla js. I have a navbar with links to sections. I want to make the class active as soon as the section becomes active. If there are no active section, then remove the active class. Found such a script, but there is one drawback. If I am in an inactive section, the active class will remain…
Axis moving to center of graph after upgrading D3 from v4 to v6
I have just upgraded my d3 version from v4 to v6 and had made no changes to the way I draw my graphs yet. Before when the minimum and maximum data values were all 0 the x-axis at y = 0 would be set on the bottom of the chart which is what I am trying to keep. Now it
Change aria attribute value using JavaScript Observer method
Can someone provide me with an example of an HTML div element with an attribute of aria-highlight that changes and notifies the element using the JavaScript observer method? An example would be using a checkbox that toggles the div and changes the background of the div element. I need this done in vanilla Jav…
“Uncaught SyntaxError: Cannot use import statement outside a module” When Importing ReactJS
Today I decided to try to learn React, but whenever I try to import the two modules below: I get the error: Uncaught SyntaxError: Cannot use import statement outside a module Here’s the steps I’ve taken to try to create my React program: Install NodeJS Add NodeJS to environmental variables Create …
Smart Drag Using JS?
Would it be possible to stop an element from dragging once it reaches the edge of the screen? I have been trying for the past hour with no luck. Here is my code so far: I thought I could use the clientHeight and clientWidth, but so far I have been unsuccessful. Any help would be much appreciated. Answer I ren…
Recursion question: Create array where each letter occupies an index of the array
I am using javascript. I am new to recursive functions, and cannot seem to figure out how to express this logic recursively: ” Write a function that accepts a string and creates an array where each letter // occupies an index of the array. ” (Firstly,) I think the question is asking me to do the f…
Importing a function in Vue 3 setup
Currently, im trying to call a throttle/debounce function in my Vue component, but every time it’s called a Uncaught TypeError: functionTD is not a function si throw here is my code. useThrottleDebounce.ts and this is when it’s called inside setup in my component Answer The issue is that useThrott…
Multiple tile issue google maps API v3 JS
I have a map where user from an admin panel can add many tiled layers to the map. Those layers will be added to the map in the form of loop. The user can switch the layer on and off based on their selection. After adding the layers via the loop when I select the first layer the second layer
Async and promise function do not display anything in my res.json call
I have a controller in javascript which should get a given user, and then the pets that are associated with the user. The related pets are stored in an array of object refs within the user schema. At the minute, when I try to res.json the resulting array containing the related pets, it outputs as an empty arr…
Highcarts, removes html on categories
So I have this issue where i pass in categories with html, but if I send in the only thing that comes out is Does anyone know why this happens? Here is the code for the highchart. This has worked before and I haven’t changed anything that I can remember. These are all the details I have to post. How