I have a <p>
with a paragraph inside and a button.
I would like to display 40 characters when I click the button. And display the entire paragraph if I click on it again.
Here is my code :
const [showText, setShowText] = useState(false)
<div>
<ImCross onClick={() => setShowText(!showText)} />
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Atque consectetur debitis deserunt dicta dignissimos est et excepturi facere facilis fugit id in, ipsa quae reiciendis repellendus suscipit unde veniam voluptas.</p>
</div>
<ImCross />
is the button to hide and show text.
Now I'm totaly lost on how can I get the .length
of the <p>
, and change the number displayed on click.
Any help ?