When I pressed Ctrl + A (Command + A), it's select all text in the page. how can I select only the letters inside the selected div when I pressed Ctrl + A (Command + A)?
Below is my full code.
import React, { useState } from 'react';
const Test = () => {
const [chatList, setChatList] = useState([]);
const onSubmit = (e) => {
e.preventDefault();
const value = e.target[0].value;
setChatList([...chatList, { value }]);
};
return (
<div>
<form onSubmit={onSubmit}>
<textarea placeholder="Enter text"></textarea>
<button type="submit">submit</button>
</form>
{chatList.map((chat, index) => (
<div key={index} style={{ whiteSpace: 'pre-wrap' }}>
{chat.value}
</div>
))}
</div>
);
};
export default Test;