23 lines
762 B
JavaScript
23 lines
762 B
JavaScript
document.addEventListener('DOMContentLoaded', function () {
|
|
const searchInput = document.querySelector('.search-box');
|
|
const searchButtons = document.querySelectorAll('.search-buttons button');
|
|
|
|
searchInput.addEventListener('keypress', function (e) {
|
|
if (e.key === 'Enter') {
|
|
const query = searchInput.value;
|
|
if (query) {
|
|
window.location.href = `search.php?q=${encodeURIComponent(query)}`;
|
|
}
|
|
}
|
|
});
|
|
|
|
searchButtons.forEach(button => {
|
|
button.addEventListener('click', () => {
|
|
const query = searchInput.value;
|
|
if (query) {
|
|
window.location.href = `search.php?q=${encodeURIComponent(query)}`;
|
|
}
|
|
});
|
|
});
|
|
});
|