I am currently rendering three buttons using a .map method in React. The buttons are being pulled from an array in a useState. When clicked, the buttons have a .active class added to them. How can I set the first element to have the .active class when the page is first loaded? Current Code: https://codesandbox.io/s/recursing-lake-oetxj?file=/src/App.js Tried setting the first activeObject
Tag: button
Vanilla JavaScript: How to dynamically create a button that shows up after user has selected some text and then do something with that text?
I’m working on a little project in which users can upload their .docx files and then read those files (and files from other users) right in the app. For this purpose I have extracted text from docx and displayed it in a div in separate view and html page. Now, I would like to give my users an option to
Loading spinner disables HTML5 required attribute
I have submit button (bootstrap) where i submit some data from input fields to my PHP query. I have added to this submit button a loading spinner after the button has been clicked by the user. Since i have added the spinner id to the button the HTML attribute for “required” is not longer working. It does not indicate the
How to add a button to run code inside LeafletJS marker?
I am trying to add a button inside a pointer which print a log to the console. This is just meant to be a test, so I can actually make the marker run a method, but I can’t even get it to print text. When I load the page, I immediately get this error: Uncaught (in promise) TypeError: Cannot read
What is the best way to make these buttons insert specific text into a text field?
I’ve made a virtual keyboard that has Russian characters and Latin characters. I want to make each character key on the virtual keyboard (.keyLetter) insert the Russian character (.primary) into the text field. Additionally, I want to make each physical keyboard keypress activate the corresponding buttons onscreen, so that the user can type by clicking the onscreen keys, or by
Why is there an error with onclick function?
I’m working on an assignment that asks us to use Promise, and when I run the script, I am getting this error on line 37: Uncaught TypeError: Cannot set property ‘onclick’ of null I can’t understand why the onclick is throwing this error, because I have used buttons before with similar functionality, and never had an issue. Code is below:
Prevent clicking on the black border
Clicking on the black border turns it on. The button part is the middle part. What would be changed in the code to have only the middle part be clickable? Multiple buttons. https://jsfiddle.net/pc47hwgd/ I was able to do it when there is only 1 button, but not when there are multiple buttons on the screen. https://jsfiddle.net/gypw370q/ Answer You need set
How switch Bootstrap 5 tabs (button version) with javascipt
I want to programmable switch tabs (using bootstrap 5). Bootsrap docs say: As a best practice, we recommend using elements for the tabs, as these are controls that trigger a dynamic change, rather than links that navigate to a new page or location. So I want use buttons instead links. Code: Problem is wrong selector. But I have no idea
Button value output in console.log with JS
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.
“Button” shrinking after applying JS function
I am trying to build a timer. I am in the process of coding the play and reset button. It seems to work well, except that the “button” for the play or reset button would shrink after I clicked it once, and a refresh is needed to make it the original size again. I have tried to see if there