Jquery 将变量中的产品信息注入‘;主体’;页首
我是html和jquery的初学者,所以简单点。我的XML文件中有我所有的产品信息。然而,我需要一些关于如何在我的每个不同产品页面上显示实际产品信息的建议 非常感谢您的帮助。这就是我目前所拥有的。如何让数据变量显示在页面上Jquery 将变量中的产品信息注入‘;主体’;页首,jquery,html,xml,Jquery,Html,Xml,我是html和jquery的初学者,所以简单点。我的XML文件中有我所有的产品信息。然而,我需要一些关于如何在我的每个不同产品页面上显示实际产品信息的建议 非常感谢您的帮助。这就是我目前所拥有的。如何让数据变量显示在页面上 var title = $theProduct.find('title').text(); var brand = $theProduct.find('brand').text();
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'); // This is an XML object containing the child data objects of the 'spec'
var specification = [];
$spec.children().each(function() {
specification[$(this).prop("tagName")] = $(this).text();
});
// The 'specification' variable is an associative array of the spec child data values that are indexed via the child tag name
var imageFilename = $theProduct.find('picture').text();
($id + "" + title + ":" + brand + ":" + price + ":" + description + ":" + imageFilename);
for(var key in specification)
{
console.log(key + ":" + specification[key]);
}
}
});
});
这是一个模糊的问题,但作为“如何让数据变量显示在页面上”的基本答案。请尝试类似$('body')的方法;作为一个基本的出发点。根据需要,html也可以代替.append。希望这对你有所帮助。谢谢你的帮助。如何让它显示在特定页面上。因为我有多个产品页面。