Reputation: 15
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>
Upvotes: 0
Views: 3868
Reputation: 1520
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>
);
}
Upvotes: 1