score:0
Accepted answer
class Demo extends Component {
//suppose you have a list something like this
state = {
owners:[{"name" :" owners1"}, { "name": "owners2"}, { "name" : "owners3"},{ "name" : "owners4"}]
}
render() {
return (
<div >
{ this.state.owners.map((it) =>
( <li><a href="#">{it.name}</a></li>)
)}
</div>
);
}
}
export default Demo;
score:0
In React you can add a simple onClick
-Attribute like that:
<li onClick={function () {
alert(owners.locationOwner);
}} > {owners.nameOwner}</li>
It is basically onClick={}
that takes in a function. This function is called when the onClick-Event happens.
Source: stackoverflow.com
Related Query
- Click on Name - shows phone Number React
- React - How to format phone number as user types
- React Native Phone Number Input
- How do I remove the international option in React Phone Number Input?
- Not able to fetch user details when i am click on customer name which is display in react table
- React Phone Number input format and Output without format
- get name from a button click React
- In the following code How do I change code so it shows the lent details of the corresponding name when I click the notes.name button?
- React Tic Tac Toe tutorial: can you explain how a number is passed as an argument to the function of the click event?
- Shows random number enqueuesnackbar (notistack) in react js
- How to change default style of React Phone Number input field
- On iOS React text/number input is stuck forcing user to enter in phone number
- How to validate the phone number using react
- react shows error when submit button click
- how to create random number with click event in react
- React class name shows object
- How to get React button's click events and class name from vanilla javascript?
- How to get the phone number not the country code in MuiPhoneNumber in React
- How to validate phone number in react that until user give valid phone number button should disabled
- Phone number validation in React JS - how to limit type and length of input?
- React useStyles Remove class name on click
- Get phone number prefix from Cookies in React
- React input saves the input at first click then shows it in the UI on second click... WHY ?!!! and how to fix it
- how to I get the user phone number after verification in react using firebase phone auth
- React JS - input onChange event not setting phone number as valid until 1 extra character typed
- react phone number validation
- Detect click outside React component
- React / JSX Dynamic Component Name
- Dynamic tag name in React JSX
- Uncaught Invariant Violation: Too many re-renders. React limits the number of renders to prevent an infinite loop
More Query from same tag
- How to customize table row height in Antd?
- How to add font ttf file in nextjs
- How in Typescript can I upgrade array of variable from class A to class B, which is extended from A?
- Typing reducer with redux-actions library
- Could anybody please help me to rewrite this code using useEffect()?
- × TypeError: Object(...) is not a function
- How to show hand hover on ReactTable rows in "React.js"
- DraftJs creating simplest possible custom block
- How to install packages in just one package.json file in Yarn workspaces?
- Get filename in Rails backend from file upload in React frontend
- Number input is string not integer in React
- The states is updating but not rendering
- The pseudo class ":first-child" is potentially unsafe when doing server-side rendering. Try changing it to ":first-of-type"
- Adding External JS file to React JS Project
- Control the URL bar with JavaScript
- How to set modal scroll to top when it appears in React.js
- MenuIcon not found in MUI
- bundle.js not found while refreshing the page having ID in it's URL
- Ticking seconds with custom setInterval hook
- add new data inside redux state tree
- Cloud Firestore Query with React - First Character Is Numeric
- Filtering an object with multiple filter values
- Docker image build getting stuck at "npm install" for ReactJS
- How to open and close dropdown on btn-click, but in same time with outside click close?
- Module not found: Error: Can't resolve 'react-dom/client'
- Where to initialize Auth0 lock in a react app
- React-Vega - WARN Infinite extent for field "x": [Infinity, -Infinity]
- calling a method from outside of class (React.js)
- ReactJS, event.currentTarget doesn't have the same behavior as Vanilla Javascript
- i'm using react hook useEffect to fetch an advice api. it changed automatically after every page refresh how can i do it automaticly using a button