-
Notifications
You must be signed in to change notification settings - Fork 0
/
plant_goodness.js
57 lines (38 loc) · 1.19 KB
/
plant_goodness.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
52
53
54
55
56
57
var data=[{
"image":" https://mamaearthp.imgix.net/wysiwyg/Ritu_Image.png",
"h2":"A much needed initiative in the present times,just by taking a small step this can bring about a big change",
},
{
"image":"https://mamaearthp.imgix.net/wysiwyg/2nd_Quote_1.jpg",
"h2":"Thanku for initiating much needed programme which contributes back to our environment",
}]
var i=0
var divv=document.createElement("div")
divv.id="main1"
var img=document.createElement("img")
img.src=data[i].image
var hea=document.createElement("h2")
hea.innerText=data[i].h2
divv.append(img,hea)
document.getElementById("btn").addEventListener("click",myfun)
function myfun(){
i++
document.getElementById( "middle").innerHTML=""
if(i==data.length){
i=0
}
// data.forEach(ele => {
img.src=data[i].image
hea.innerText=data[i].h2
divv.append(img,hea)
document.getElementById("middle").append(divv)
// for (var i=0;i<data.length;i++){
// document.getElementById("seventh").append.data[i]
// if(data[i]==data.length){
// data[i]==0
// }else{
// i++
// }
// }
// });
}