Reactjs! Make Span tag clickable

The name of the pictureThe name of the pictureThe name of the pictureClash 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>
&nbsp;(&nbsp;
`$person.name,$person.address `
&nbsp;)
</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.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard