jeremyjia / Games

Home Page Link:
https://jeremyjia.github.io/Games/
3 stars 8 forks source link

Press button New UI,刷新页面并显示所有的图书信息 #850

Open waynexw opened 1 year ago

waynexw commented 1 year ago
    按New UI,刷新页面并显示一个完整的图书信息包括title price and picture.

Originally posted by @waynexw in https://github.com/jeremyjia/Games/issues/812#issuecomment-1320853183

waynexw commented 1 year ago

image

关键代码: image

waynexw commented 1 year ago

问题: 如果在以上代码前面再加上如下代码,则显示所有图书信息,而并非一本书。但变量s中只写了一本书的数据代码。 image

jeremyjia commented 1 year ago

问题: 如果在以上代码前面再加上如下代码,则显示所有图书信息,而并非一本书。但变量s中只写了一本书的数据代码。 image

不错不错,已经呼之欲出了

waynexw commented 1 year ago

var allbooks = function(o) { var r = ""; r += "<h1 id=\"demo_book\" class=\"modal-body\">Benny Wonderland List"; var k = 0 for (i in o) {
r += "<div class=\"post\" data-price=\"500\" data-city=\"Eugene\" data-condition=\"excellent\">" r += "<div class=\"post-contents\">" r += "<div class=\"post-image-container\">" r += "<img id=\"book_pic0\">

" r += "<div class=\"post-image-container\" id=\"book_title0\">
" r += "<div class=\"post-info-container\">" r += "<span class=\"post-price\" id=\"book_price0\"> <span class=\"post-city\">(Corvallis)"
r += "" r += "" k++; }

//单引号、双引号在javascript、HTML中的转义字符

              return r;
            }