I’m fairly new to HTML and JS. I need the value of my HTML button to show in the console.log with JS. I dont want to use onclick=”…” though. This is part of my HTML file: This is my JS file: Answer 1) You have to add event listener on the html element not on the value of that element.
Category: Questions
Retrieve information from a route according to the route dynamically
I have created routes to display the pages that are linked to them, I now want to retrieve this information when I am in a page. Here is an example of a route: I want to display for example the ID in my header, how can I do ? I tried this solution but I can’t get the routes with
How do I take input via html input tag on button click and add it to a list USING JQUERY
I am a student and currently learning jquery <– I am trying to make the function that will take input from the inputbox and then add it to the unordered list as an EXTRA Using jQuery create an input and a button. When clicking on the button it should invoke a function addToList that will use the inpu…
Only allow one React Accordion to be expanded at once
I have an array of data that will be used to create accordions, I’d like to make it so that only one of them can be expanded at once (i.e, if the user expands accordion #1 and then #2, #1 will un-expand) I have this code: I’m quite new to React so I suspect I’ve made a mistake with the
TypeError: cb is not a function in nodejs?
(node:13384) UnhandledPromiseRejectionWarning: TypeError: cb is not a function I am using passport js for authentication for my website, I am able to get all routes but when I try to sign up that is post router so in the console I am seeing these err, my data saved in DB but after posting my page loading cont…
Data defined, but return undefined
I get an error after compiling it but I have defined it and fetch the data using async await but get a TypeError: data[index] is undefined I have stuck for several hours and still come out with no solution. Furthermore, I have tried to destructed it but still get the same error. Using data.map() works, but I …
How to override div onClick event when button is clicked?
I am trying to stop the parent div from executing an onClick event when the child Delete button is clicked. I tried to implement event.stopPropogation however, it gives me an error. Answer In case anyone has the same problem as me, simply use e.stopPropogation(). This stops the click event from bubbling up to…
React setState not updating
In this code in the else block, when the setState function is called, the state doesnot change Note: Even if it is asynchronous it doesn’t change it all after a long time Could this problem be because of the ES6 destructuring of the state EDIT I logged and checked with a callback and still the state rem…
How to build links with fragments taken from text fields, but within a JavaScript to randomize them before open each of them on its own tab
I’m trying to make one single JavaScript able to randomize several links which must be built with fragments taken from text fields, before opening each of them on its own tab, by clicking a button. I know 2 different JavaScripts to separately do both things: a) build URLs with fragments taken from text …
How to fix this “Syntax error:Unexpected identifier”?
I am trying to make an js contact app program that has to save a Contact number and phone and I get this error “Unexpected identifier at line 61”. I don’t know where seems to be the ending point, how can I solve this? Here is my code: Also I get this error too when I try to save the