Use javascript program to realize the coffee web page made before

  After a preliminary understanding of Javascript in the past two days, in today's class, Mr. Wang took us to help us make the previous coffee introduction page with script. Compared with the previous div, a lot of decoration and definition were required. Javascrpt can loop through a for statement. to solve, very convenient. But I still couldn't make it at the beginning. The problem is that the output format of document.write() is wrong. The output of document.write() is similar to the previous output. The output pictures, titles, and paragraphs can be replaced by elements in the defined array, such as var coffees=[
{
img:'.....',
title :'......',
detail:'....... '

},

                      {
img:'.....',
title:'......',
detail:'....... '

},  ..............]

for (var i = 0; i < coffees.length; i++) {
document.write('<div class="wrapper"><img src="'+coffees[i].img+'"><h3>'+coffees[i].title+'</h3><p>'+coffees[i].detail+'</p></div>')
}

  +coffees[i].img+ is equal to the address of the picture quoted in the i-th paragraph + sign indicates the connector



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326072543&siteId=291194637