HTML
<template>
<div>
<h1>{greeting}{name}</h1>
<input type="text" value={name} onchange={handleChange}/>
<button onclick={handleClick}>Say Hello</button>
<select onchange={handleSelectChange}>
<option value="en">English</option>
<option value="fr">French</option>
<option value="es">Spanish</option>
</select>
</div>
</template>
Java Script
import { LightningElement } from 'lwc';
export default class EventExample extends LightningElement {
name = 'World';
greeting = 'Hello';
handleChange(event) {
this.name = event.target.value;
}
handleClick() {
this.greeting = `Hello, ${this.name}!`;
}
handleSelectChange(event) {
const language = event.target.value;
if (language === 'en') {
this.greeting = 'Hello';
} else if (language === 'fr') {
this.greeting = 'Bonjour';
} else if (language === 'es') {
this.greeting = 'Hola';
}
}
}
Video
Video does not exists.