var keywords = [
{"keyword": "Sample 1", "item": {"title":"Sample Title", "url": "/sample"}},
{"keyword": "Foo 1", "item": {"title":"Foo Title", "url": "/sample"}}
];
$("#query").on('keyup', function() {
var search = this.value.toLowerCase();
var result = $.grep(keywords, function(el) {
return el.keyword.toLowerCase().indexOf(search) > -1;
});
log(result)
});
function log(rows) {
var str = '';
$.each(rows, function(i, row) {
str += JSON.stringify(row) + '<br>';
});
$('#log').html(str);
}
{"keyword": "Sample 1", "item": {"title":"Sample Title", "url": "/sample"}},
{"keyword": "Foo 1", "item": {"title":"Foo Title", "url": "/sample"}}
];
$("#query").on('keyup', function() {
var search = this.value.toLowerCase();
var result = $.grep(keywords, function(el) {
return el.keyword.toLowerCase().indexOf(search) > -1;
});
log(result)
});
function log(rows) {
var str = '';
$.each(rows, function(i, row) {
str += JSON.stringify(row) + '<br>';
});
$('#log').html(str);
}
Comments
Post a Comment