【发布时间】:2023-01-12 23:59:32
【问题描述】:
` I am trying to make FAQ section but problem here with my code is when i am clicking open(+)
Button of particular section it will open all the section and same case with close(-) button
also.`
```
export default function App() {
const [isOpen,setIsOpen] = useState(false)
return (
<div className="App">
<h1>Faq/Accordian</h1>
<div className="accordian">
{questions.map((ele)=>(
<div key={ele.id} className="faq">
<h3>{ele.title}</h3>
<button onClick={() => setIsOpen(!isOpen)}>{isOpen ? "-" : "+"}</button>
{isOpen===true && <h4>{ele.info}</h4>}
</div>
))}
</div>
</div>
);
}
```
我期待当我点击特定的打开按钮时它应该打开那个特定的部分
【问题讨论】:
标签: javascript reactjs toggle