【发布时间】:2018-03-04 04:03:37
【问题描述】:
我有一个名为“LaptopsImages”的图片文件夹。
在我的名为laptops.php 的文件中,我有一个包含不同笔记本电脑的数组列表,其中包含以下变量:标题、品牌、价格、描述、规格和图片名称。我的数组列表转换为 XML DOM 树。
在我的名为 product.html 的文件中,我编写了一个代码,将每个产品数据放入变量中并显示出来:
var title = $theProduct.find('title').text();
var brand = $theProduct.find('brand').text();
var price = $theProduct.find('price').text();
var description = $theProduct.find('description').text();
var spec = $theProduct.find('spec');
var imageFilename = $theProduct.find('picture').text();
document.getElementById("title").innerHTML=title
document.getElementById("brand").innerHTML=brand
document.getElementById("price").innerHTML=price
document.getElementById("description").innerHTML=description
document.getElementById("spec").innerHTML=description
除了每台笔记本电脑的图片外,我已将所有产品数据显示到我的 html 中。有什么方法可以显示具有我变量中已有名称的图片吗?假设图片名称为“0001.jpg、0002.jpg”等。
每张图片都可以取自: var imageFilename=$theProduct.find('picture').text();
【问题讨论】:
标签: javascript php jquery html image