I'm doing a live search results feature for my website. I have a JSON object containing key terms that I'd like to match the value of an input to.
The best solution I could think of for this was to iterate through each term in a loop and look for a partial matches with a jQuery selector. How can I make an if statement like this? For example:
$.getJSON('jsonfile.json', function(data) {
key = Object.keys(data);
for(i=0;i<key.length;i++)
{
if($(input[value]:contains == key[i].term)
{
//do something
}
}
}
EDIT: My apologies for being unclear. I'm using the :contains selector for partial matches on the value of one input.