Answer the question
In order to leave comments, you need to log in
How to limit the number of displayed values?
$(document).ready(function(){
$('#search').keyup(function(){
$('#result').html('');
var searchField = $('#search').val();
var expression = new RegExp(searchField, "i");
$.getJSON('goods.json', function(data){
$.each(data, function(key, value){
if(value.name.search(expression) != -1 || value.location.search(expression) != -1)
{
$('#result').append('<li style="list-style-type: none;margin:2px;border-bottom:1px solid #333;"><a href="'+key+'" title=""><img src="'+value.img+'" height:"40" width="40">'+value.name+'</a></li>')
}
});
});
});
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question