Reactjs! Make Span tag clickable
Clash Royale CLAN TAG#URR8PPP
Reactjs! Make Span tag clickable
Reactjs! I am trying to make span tag clickable only where it says person.name(It should display $person.name in blue) and when it clicks i want to display a popup box which helps to edit the name.Please Help.
<span>
(
`$person.name,$person.address `
)
</span>
1 Answer
1
You can add onClick to a span and call your function. Something like this: (i have also added the styles. You can replace the hardcoded "name" with state )
const clickspan1 = () =>
alert('name');
return (
<div className="App">
<h1>Hello CodeSandbox</h1>
<h2>Start editing to see some magic happen!</h2>
<span style=color:'blue',cursor:'pointer' onClick=clickspan1 >Name</span>
<span>address</span>
</div>
);
}
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.