Your HTML is malformed (your GetKey
function call is using double quotes inside double quotes). That is causing issues potentially but since you're using Razor I haven't tested it. Your initial function is trying to hook up the event before the element is even defined so that would fail as well. The browser's console window should be showing you errors for these.
Here's the simplest equivalent code to do what you want.
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#SearchInput").keyup(function (event) {
var searchText = event.target.value.toLowerCase();
console.log(searchText);
})
})
</script>
</head>
<body>
<ul>
<li class="search">
<a class="fa-search" href="#search">Search</a>
<form id="search" method="get" action="#">
<input id="SearchInput" type="text" name="query" placeholder='@language.Getkey(" search")' />
</form>
</li>
</ul>
</body>
</html>