forked from prograd-org/lab-javascript-oops-blog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
41 lines (39 loc) · 1.38 KB
/
script.js
File metadata and controls
41 lines (39 loc) · 1.38 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* Fill your code*/
class Blog{
constuctor(title,detail){
this.title=title;
this.detail=detail;
}
addTitle(){
var title_card = document.createElement('h1');
title_card.setAttribute("id","blog-title");
console.log(title_card);
document.getElementById('card-text').appendChild(title_card);
title_card.innerHTML += this.title;
}
addDescription(){
var description_card = document.createElement('p');
description_card.setAttribute("id","blog-description");
console.log(description_card);
document.getElementById('card-text').appendChild(description_card);
description_card.innerHTML += this.description;
}
}
var p=document.getElementById('post');
var b=document.getElementById('Blog');
var c=document.getElementById('close');
b.addEventListener("click",function(){
p.style.display="block";
});
c.addEventListener("click",function(){
p.style.display="none";
});
document.getElementById("post").addEventListener("click",function(){
document.getElementById("post").style.display="none";
var $img=document.createElement("img");
$img.setAttribute("src","./assets/javascript.png");
document.getElementById("card-text").appendChild($img);
var $title=document.getElementById("title").value;
var $detail=document.getElementById("detail").value;
var object1=new Blog($title,$detail);
});