<ul id="menu">
<li data-action="save">Save
<li data-action="load">Load
<li data-action="search">Search
</ul>
JS
class Menu {
constructor(elem) {
this._elem = elem;
elem.onclick = _ => this.onClick(event)
}
save() {
//action
}
load() {
//
}
search() {
//action
}
onClick(event) {
let action = event.target.dataset.action;
if (action) {
this[action]();
}
}
}
new Menu(menu);