How to get the source of button in Lightning webcomponent
buttonFunctionality.html
========================
<template>
<lightning-button-group>
<lightning-button label="Refresh" onclick={handleClick}>
</lightning-button>
<lightning-button label="Edit" onclick={handleClick}>
</lightning-button>
<lightning-button label="Save" onclick={handleClick}>
</lightning-button>
</lightning-button-group>
</template>
buttonFunctionality.js
======================
import { LightningElement,track } from 'lwc';
export default class buttonFunctionality extends LightningElement
{
handleClick(event)
{
const buttonalabel=event.target.label;
alert(buttonalabel);
}
}
LighntingApplication
====================
<aura:application extends="force:slds">
<c:buttonFunctionality/>
</aura:application>
========================
<template>
<lightning-button-group>
<lightning-button label="Refresh" onclick={handleClick}>
</lightning-button>
<lightning-button label="Edit" onclick={handleClick}>
</lightning-button>
<lightning-button label="Save" onclick={handleClick}>
</lightning-button>
</lightning-button-group>
</template>
buttonFunctionality.js
======================
import { LightningElement,track } from 'lwc';
export default class buttonFunctionality extends LightningElement
{
handleClick(event)
{
const buttonalabel=event.target.label;
alert(buttonalabel);
}
}
LighntingApplication
====================
<aura:application extends="force:slds">
<c:buttonFunctionality/>
</aura:application>
Comments
Post a Comment