I Want to Trigger Collapse Components for Example Accordion ( accordion ) This is Happening Based on Attributes but i need on OnClick Function How can we modified this or any specific Function which is running behind how we can trigger those function in on click events
Hi Rakul,
You can still use onClick event on your accordion elements.
Here is an example:
const handleItemClick = () => {
// handle item click here
}
const handleAccordionClick = () => {
// handle accordion click here
}
<div onClick={handleAccordionClick} className="accordion" >
<div onClick={handleItemClick} className="accordion-item">
<h2 className="accordion-header" >
<button className="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#panelsStayOpen-collapseOne" aria-expanded="true" aria-controls="panelsStayOpen-collapseOne">
Accordion Item #1
</button>
</h2>
<div className="accordion-collapse collapse show" aria-labelledby="panelsStayOpen-headingOne">
<div className="accordion-body">
<strong>This is the first item"s accordion body.</strong> It is shown by default, until the collapse plugin adds the appropriate classNamees that we use to style each element. These classNamees control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It"s also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
</div>
</div>
</div>
</div>
So the Attributes Should be Removed Right if we are doing using events
Hi Rakul,
Attributes are still required to initialize your accordion element. You can use these click event handlers to execute your code.
Regards,
Lauris Stepanovs,
Keenthemes Support Team