News Articles onclick

Best way to write onClick multiline function?

I have this onClick function that shows the details of the user and then sets another state back to true. Would it be better to declare this function outside of the return as it is multiline? and if so how should I write it? <Button onClick ={() => {setSelectedUser(user); setShowUser(true);}}>{}</Button> Here the rest of my […]

Issue with onClick on fast re-redering React table

I have a table in React app which displays price changes in real-time. Some of the prices gets updated between 50 and 150 times per minute, and it force the whole table to re-render. Each TR have a unique ID and I need to expand some additional data on a single row click. I am […]

Passing value to function in on button click but its not pass the vlaue

I’m facing an issue, when i click on the update or delete button it’s not passing any value to the function. Please help me out. Onclick update it should pass _name to updatereview function and same to delete when click on delete it should pass the val.movie_name to "deletemoviereview" functuion import React,{useState,useEffect} from ‘react’; […]

background color change when clicked 2x

I need a button which can change the background color if you click it 2x. How can I do this?, I only know how to do it with 1 click. My code is actually this: <button onClick=" =’#000′;"> color </button> Source: CSS – Stack Overflow

onClick doesn’t work on Button Style Component in Mobil View

I have a styled.button that works perfectly on desktop view, but when on my desktop I toggle to mobile view it doesn’t work at all. Button: const DateElement = styled.button` background-color: ${(props) => (props.primary ? ‘#DEE2FF’ : ‘#696B86’)}; color: ${(props) => (props.primary ? ‘black’ : ‘#dedee4’)}; box-shadow: none; padding: 9px; width: 90px; text-align: center; height: […]

target.addEventlListener("click", () =>{ Not working?

I am trying to create a slideshow but the addEventListener is not working !! i am beginner in js world and want to get better by projects but this simple project has stumped me. const nextBtn = document.querySelector(".next-btn"); const prevBtn = document.querySelector(".prev-btn"); const slides = document.querySelectorAll(".slide"); const slider = document.querySelector(".slider"); const slideIcons = document.querySelectorAll(".slide-icon"); // […]

An onClick() event works on one div, but not another. Why?

Using React, I have one div that contains information, and another div inside of it that contains a list of items. I want this second div(the list) to be collapsible on click. If I put the click listener into the first div, it works and shows the list of items. The problem with this is […]

How to import text from one JS file and then pass that dynamically as prop values to a component defined in a different file; in react js?

I have a tree.js file that looks like this: (the values to be taken as prop values have been mentioned in comments) const treeData = { ‘first-level-node-1’: { label: ‘Phytophthora agathicida’, index: 0, nodes: { ‘Phyag_NZFS3770’: { label: ‘Phyag_NZFS3770’, // prop value 1 index: 0, }, ‘Phyag_NZFS3772’:{ label: ‘Phyag_NZFS3772’, // prop value 2 index:0, } […]

onclick button redirect with variable on same page?

First off, I’m quite new to HTML, CSS and JS and I’ve spent a long time trying to figure something out that may be relatively basic, so I’d appreciate any advice (or a link to a similar question already asked). I’ve been building a B2B website for my employer where each logged in client needs […]

React can’t fire onClick

All the events on the Article: onMouseMove, onMouseDown etc. are correctly executed. But onClick don’t. I can see the button but clicking in it nothing happens. Button showed const onDelete = () => { console.log(‘delete’) }; return ( <> {show && <Ul style={{top: pos.y, left: pos.x}}> <Li> <Button onClick={onDelete}> <Trash /> Delete </Button> </Li> </Ul> […]

Link onlick with a function

I have an array of list of products, (with unique id, name, price, etc) at "products.html" (with js) Each product has a button, "MORE INFO". I want to click on that button, and see the detail of THAT product (each product has different information detail, ending in another html (detail.html)). My code: const listShirts = […]

Render a different image each time the user selects an option in React.js

I have a form with a select with multiples options. I want that every time the user clicks on any of the options, the image to the right of the form changes. The thing is that every time I select an option, the name of the variable is placed in the SRC of the image […]

how to remove any function in onclick button?

I am trying to stop a function when I click on the open button because that function causes some height width problem I don’t want to use that function when I click on the button after that when clicking on the close button it should start again here is the code <a class="open" href="javascript:;" id="show-comment"/> […]

get element.innerHTML via pure JS from tablerow//<tr onClick(myFunction>

I am trying to enable a pop-up window with information on the clicked table element. Therefore I wanna get the element ID of the clicked element. Thanks đŸ˜€ Problem I always get the same ID//table element no matter which table entry I click. HTML Page with a table which displays data from the database {%extends […]

Hide Modal popup 1 upon Modal popup 2 opens React Js

I have a Modal popup (1st) upon clicking on that modal popup I wanted to open another Modal popup (2nd). I’m able to achieve this however I’m not able to close the 1st Modal popup upon 2nd Modal popup opens, However I have tried to achieve this by wrapping up the multiple function events called […]

Neither onClick nor addEventlistener is applying

Browser does neither read addEventListener nor onClick. When I open the console and try executing $0.onclick($0 is the element I am trying to use onclick on) returns null. var view = d.createElement("a"); view.href="javascript:void(0)"; view.className = "view"; view.draggable = false; view.addEventListener("click", viewFile); //onClick is also not working. function viewFile() { //Code here } Can anybody help […]

how do i replicate the onclick event present in a div? [closed] this is website for reference this is the div in question <span class="base__BFInputPlaceHolder-sc-3hhs49-7 cgtpHC">Going to…</span> ` code that I tried $(‘destinations__BFDestMenu-pia0lx-2 gtqfDf’).trigger( "click" ); I want to replicate the onClick event that happens when u click on destination this is the output that i get on console k.fn.init [prevObject: k.fn.init(1)] Source: JavaSript – Stack Overflow

Can a React JS class be called via an onClick listener in another Component?

I have code that looks like so: import React from "react"; import Overlay from "./Overlay"; export default class TagListItem extends React.Component { render() { return( <div className={‘tag’} onClick={() => <Overlay data={this.props}/>}> {this.props.tag} </div> ) } } Using breakpoints I’ve been able to figure out that the onClick event triggers, but my Overlay class doesn’t get […]

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.