在jQuery Mobile的列表视图搜索 [英] listview search in jquery mobile

查看:121
本文介绍了在jQuery Mobile的列表视图搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    <ul id='list' data-role='listview' data-filter='true' data-inset='false'>
    <li id='a1'>
        <h3>ABC</h3>
        <p>this is ABC</p>
    </li>
    <li id='a2'>
        <h3>DEF</h3>
        <p>DEF is not ABC</p>
    </li>
</ul>

例如,

搜索ABC,结果是ABC和DEF。

search 'ABC', result is ABC and DEF.

但我不希望搜索&LT; P&GT; 标签,只搜索&LT; H3&GT; 标签

but I don't want to search <p>tag, search only <h3>tag.

如何做到这一点。

推荐答案

呃......这里是一个开始......

Well... here is a start...

$("#list li").each(function(){

    if($(this).
              find("h3").
              text().toUpperCase().
              indexOf(SEARCHWORD.toUpperCase()) >=0)
       $(this).show();
    else
       $(this).hide();

});

查看演示

这篇关于在jQuery Mobile的列表视图搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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