blob: 9f8862b013805be646a08290fa3fa3536e8c3d3e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
class Article {
Container: HTMLElement;
Title: HTMLElement;
Image: HTMLElement;
constructor(title: string, description: string, article_link: string, image_link: string) {
// object initialisation
this.Container = document.createElement('div');
this.Title = document.createElement('h1');
this.Image = new Image();
let link = document.createElement('a');
// attributes
link.innerText = title;
link.setAttribute('href', article_link);
this.Image.setAttribute('src', image_link);
this.Image.setAttribute('title', description);
// make unit
this.Title.appendChild(link);
this.Container.appendChild(this.Title);
this.Container.appendChild(this.Image);
}
}
let root = document.getElementById('root');
|