Jquery script freezing browser but working

i'm trying to make a live search for my mobile website, I don't want to query the database every time a user type a letter so I created a ordered list with all the names that can be searched for and i'm looping through it with jquery, problem is that I have 3300 names and it's freezing the browser when it searches through them, can anyone give me a tip about better ways to do it? here is my code: $(document).ready(function(){ $("input#search").keyup(function(){ var filter = $(this).val(), count = 0; var html = ""; $("ol.pacientes li").each(function(){ var nome_paciente = $(this).text(); if(nome_paciente.indexOf(filter.toUpperCase()) != -1){ html = html + " " + nome_paciente; } $('#pacientes_hint').html(html); });

以上就是Jquery script freezing browser but working的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏