-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
51 lines (40 loc) · 1.2 KB
/
app.js
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
42
43
44
45
46
47
48
49
50
51
window.addEventListener('DOMContentLoaded',function(){
console.log('App JS File is Loaded.');
// Method Calling.
// for(var i=0;i< 5;i++){
// createButton(`Button ${i}`);
// }
// createButton()
});
// Method Implementation
function createButton(buttonTitle = "Click Me"){
console.log("Create Button Method Invoked.");
let createTag = document.createElement('section');
createTag.setAttribute('class','button');
createTag.setAttribute('id','my__button');
createTag.innerHTML = `<p> ${buttonTitle}</p>`
document.getElementById('container').appendChild(createTag);
createTag.addEventListener('click',onButtonClick());
console.log(createTag);
}
function onButtonClick(){
alert("Button Click");
}
function onShowFive(){
console.log("Show 5 Buttons");
//document.getElementById('button-5').style.display = 'block';
document.getElementById('container').innerHTML ='';
for(var i=0;i< 5;i++){
createButton(`Button ${i}`);
}
}
function onShowFour(){
// document.getElementById('button-5').style.display = 'none';
document.getElementById('container').innerHTML ='';
for(var i=0;i< 4;i++){
createButton(`Button ${i}`);
}
}
function onCreateNewButton(){
createButton();
}