Below is the structure of my HTML file:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type"" content="text/html; charset=utf-8"/>
</head>
<body>
<input type="search" id="site-search" name="q"
aria-label="Search through site content" onchange="onChange()">
<script id="search_js" src="compiled/search.js"></script>
</body>
</html>
This is a snippet from my search.ts file :
const search : HTMLElement | null = document.getElementById("site-search");
function onChange(event: any) {
search.innerText = "toto";
search.textContent = "toto";
console.log("titi");
}
console.log("toto);
I intend to utilize the onChange function in my TypeScript code each time text is inputted in the search bar.
You can explore a demo on CodePen using the following link :
https://codepen.io/bussiere/pen/vYgjaej
Best Regards