默認(rèn)我想顯示所有產(chǎn)品詳細(xì)信息,我想更改匹配的產(chǎn)品詳細(xì)信息,如果選項(xiàng)值===產(chǎn)品b_name..顯示詳細(xì)信息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>
通過(guò)選擇選項(xiàng)javascript更改品牌詳細(xì)信息
大話西游666
2022-08-18 16:19:16