根据jquery中的第一个字符过滤列表字符串 [英] filter list string based on first character in jquery

查看:69
本文介绍了根据jquery中的第一个字符过滤列表字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用msdropdown jquery。在这里,它将根据我们的类型过滤li字符串。但它会搜索包含给定搜索文本的li字符串。搜索基于以下代码:



i am using msdropdown jquery. in this, it will filter the li string based on we type. but it search the li string which contains the given search text. search is based on following code:

var items = $("#" + childid + " li:Contains('" + sText + "')").show();



但我需要如果我输入字母N,它应该跳转到列表中的索引为N. br />
例如,我有一个列表苹果,香蕉,蛋糕,狗,大象,橙,球,猫,娃娃,鸡蛋

如果我输入e,现在它会将列表过滤为苹果,蛋糕,大象,橙色



但是我需要一个像这样的过滤器:elephant,egg。



谢谢


but i need that if i type letter N, it should jump to the list which li have the index of N.
For example, i have a list "apple,banana, cake,dog,elephant,orange,ball,cat,doll,egg"
if i type "e", now it will filter the list as "apple,cake,elephant,orange"

but I need a filter like: "elephant,egg" like this.

Thanks

推荐答案

(#+ childid +li:Contains('+ sText +' ))。show();
("#" + childid + " li:Contains('" + sText + "')").show();



但我需要如果我输入字母N,它应该跳转到列表中的索引为N.

例如,我有一个列表苹果,香蕉,蛋糕,狗,大象,橙,球,猫,娃娃,鸡蛋

如果我输入e,现在它将列表过滤为苹果,蛋糕,大象,橙色



但我需要一个过滤器:ele phant,egg就像这样。



谢谢


but i need that if i type letter N, it should jump to the list which li have the index of N.
For example, i have a list "apple,banana, cake,dog,elephant,orange,ball,cat,doll,egg"
if i type "e", now it will filter the list as "apple,cake,elephant,orange"

but I need a filter like: "elephant,egg" like this.

Thanks


看到:http://stackoverflow.com/questions/3715309/how-to- know-that-a-string-starts-ends-with-specific-string-in-jquery [ ^ ]



问候..
See this : http://stackoverflow.com/questions/3715309/how-to-know-that-a-string-starts-ends-with-a-specific-string-in-jquery[^]

Regards..


尝试改编这个示例代码:

Try to adapt from this example code:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>


这篇关于根据jquery中的第一个字符过滤列表字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆