const input = document.querySelector('.keyword-input');
const quickview = document.querySelector('.quickview');
const getQuickSearch = (keyword) =>{
if( keyword == '' || keyword == null || keyword == undefined ){
quickview.innerHTML = '';
}else{
const url = '/?s='+keyword+'&quickview=1';
const req = new XMLHttpRequest();
req.onreadystatechange = function() {
if (req.readyState == 4) {
if (req.status == 200) {
quickview.innerHTML = req.responseText;
}
}
}
req.open('GET',url, true);
req.send(null);
}
}
input.addEventListener('keyup',()=>{
getQuickSearch(input.value);
});
input.addEventListener('change',()=>{
getQuickSearch(input.value);
});
content_copy
コードをクリップボードにコピー