今日黄金饰品价格查询
.
.search-
.search-input:
.search-
.search-result:
.price-
.price-price:
.none-
.show-
今日黄金饰品价格查询
document.getElementById('search-form').addEventListener('submit', function(event) {
event.preventDefault();
var keyword = document.getElementById('keyword').value;
var url = https://api.example.com/gold-price?keyword=${encodeURIComponent(keyword)}&date=2022-01-01;
const response = await fetch(url);
const data = await response.json();
const price = data.price;
const priceunit = data.priceunit;
document.getElementById('price-price').innerHTML = ${price} ${price_unit};
const result = document.getElementById('search-result');
result.innerHTML = ${data.name};
const none_btn = document.getElementById('none-btn');
none_btn.innerHTML = data.none ? '热门' : '未热销';
const show_btn = document.getElementById('show-btn');
show_btn.innerHTML = data.show ? '显示' : '隐藏';
});