mr-crocs-adventures/tilorswift/js/menu/MainMenuEntry.js

22 lines
455 B
JavaScript
Raw Normal View History

export default class MainMenuEntry
{
constructor(title, event)
{
this.title = title;
this.event = event;
}
getElement()
{
let htmlElement = document.createElement('li');
htmlElement.innerText = this.title;
htmlElement.addEventListener(
'click',
() => {
window.dispatchEvent(new this.event());
}
);
return htmlElement;
}
}