Last active
June 5, 2020 17:51
-
-
Save daliborgogic/de6d20c9545e9a33c09ec8814b92eb29 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.querySelectorAll('input[type=search]').forEach(input => { | |
input.addEventListener('mouseup', e => { | |
if (input.value.length > 0) { | |
setTimeout(() => { | |
if (input.value.length === 0) { | |
// do reset action here | |
} | |
}, 5) | |
} | |
}) | |
} | |
// addEventListener version | |
const input = document.querySelector('input[type="search"]') | |
input.addEventListener('search', () => | |
console.log('The term searched for was ' + input.value) | |
) | |
// onsearch version | |
const input = document.querySelector('input[type="search"]') | |
input.onsearch = () => | |
console.log('The term searched for was ' + input.value) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment