I have a requirement where on click of lightning-carousel
dots, we need to get the lightning-carousel-image
that got clicked and we need to process the logic based on the selected image. Here I need to have onclick
event on lightning-carousel
only and not on lightning-carousel-image
Eg: LWC component
<lightning-carousel disable-auto-scroll onclick= {findClickedElement}>
<lightning-carousel-image
header={First Card}
description="First card description."
data-name="First Card">
</lightning-carousel-image>
<lightning-carousel-image
header={Second Card}
description="Second card description."
data-name="Second Card">
</lightning-carousel-image>
<lightning-carousel-image
header={Third card description.}
description="three"
data-name="Third Card">
</lightning-carousel-image>
LWCJs:
export default class lwcClassJs extends LightningElement {
findClickedElement(event){
let element = this.template.querySelector("lightning-carousel");
console.log('@@element-->'+element);
//Here I am not able to get the <lightning-carousel-image> that is clicked in UI.
}
}
Can anyone please help me how to get the lightning-carousel-image
that is displayed on the click of dot?