默认我想显示所有产品详细信息,我想更改匹配的产品详细信息,如果选项值===产品b_name..显示详细信息
let products = [
{
b_name: 'Samsung',
price: 15000,
ram: '6GB',
rom: '128GB',
},
{
b_name: 'Apple',
price: 65000,
ram: '6GB',
rom: '128GB',
},
{
b_name: 'LG',
price: 35000,
ram: '6GB',
rom: '128GB',
},
{
b_name: 'Nokia',
price: 25000,
ram: '6GB',
rom: '128GB',
},
];
let _selectBrand = $('#select_brand');
let _detailsList = $('#details');
let brandOptions = '';
for(let brand of products){
brandOptions += `<option value="${brand.b_name}">${brand.b_name}</option>`;
}
_selectBrand.append(brandOptions);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div>
<label>
<select id="select_brand">
</select>
</label>
</div>
<div id="details">
</div>
千巷猫影
相关分类