$(document).ready(function() { function product(name, description, price) { this.name = name; this.des = description; this.price = price; }var product1 = new product("iphone", "手机", 3200); var product2 = new product("huawei", "手机", 1800); var product3 = new product("nicai", "手机", 998); var product4 = new product("sansung", "手机", 3000); var product5 = new product("opera", "手机", 2000); var products = [product1, product2, product3, product4, product5]; for(var j=0;j<products.length;j++) { var pname = document.getElementsByClassName("pname")[j]; var pdes = document.getElementsByClassName("pdes")[j]; var pprice = document.getElementsByClassName("pprice")[j]; for(var i=0;i<products.length;i++) { pname.innerHTML = products[i].name; pdes.innerHTML = products[i].des; pprice.innerHTML = products[i].price; } } });
添加回答
举报
0/150
提交
取消