I'm writing a onclick
listener for a button but receiving an
Uncaught TypeError: undefined is not a function error on line 4 of this code:
$("button#searchKeyword").click(function(){
var searchTerm = $("input#searchBox").val();
var i = myArr.indexOf(searchTerm)+1;
var locationID = myArr[i].value();
alert(searchTerm + " " + i + " " + locationID );
});
The locationID
is a 4 or 5 digit integer. And myArr
is an array of strings and numbers (i.e. [string, number, string, number...]
).
I've tried adding var $ = jQuery.noConflict();
after reading this. But none of the solutions there seem to work for me.
I'm wondering if the problem is a parsing issue? Do I need to parse i
to an integer
? If so how would I do that?