I want to search a value in the array. array is predefined with some values. There will be a HTML text box to enter a value. User need to enter the value. If the value entered by user is there in array. it should display "Valued found" or else not found. It should use AJAX. My below code is not working.
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</head>
<body>
<p>Enter a value: <input type="text" id="carInput" onchange="textChanged()"></p>
<p id="onListText"></p>
<script>
var cars = ["abc", "def", "ghi","jkl"];
var textChanged = function(){
var inputText = $("#carInput").text();
if($.inArray(inputText, cars) !== -1){
$("#onListText").text("Value Found");
return;
}
}
</script>
</body>
</html>