[英]jquery mobile string search in page text
i am building a JQuery mobile App which contains lots of pages with lots of text in it. 我正在构建一个JQuery移动应用程序,其中包含很多页面,其中包含很多文本。 Initially when a user opens the app, the title of all pages is visible in a list view with search filter at the top.
最初,当用户打开应用程序时,所有页面的标题都在列表视图中可见,顶部带有搜索过滤器。 When a user clicks on the title, a new page gets opened with text on it.
当用户单击标题时,将打开一个新页面,上面带有文本。 i want to build a separate page (like search.html) with only a search input box in it.
我想建立一个单独的页面(如search.html),其中只包含一个搜索输入框。 When a person search for a string like "Some string", the tiles of all the pages which contains that term are visible in a list view and after clicking the title, the detailed page gets opened.
当某人搜索“ Some string”之类的字符串时,包含该术语的所有页面的图块在列表视图中可见,并且单击标题后,将打开详细页面。
If you're interested in all the text within, say, a <div id="theTarget">
, then* 如果您对其中的所有文本感兴趣,例如
<div id="theTarget">
,那么*
var theText = document.getElementById("theTarget").textContent;
so you can search it like any other string. 因此您可以像搜索其他任何字符串一样搜索它。
Then, based on the return value of theText.indexOf(searchText)
, you can set your corresponding list view entries' CSS styling based on whether you got -1
(no match) or not. 然后,基于
theText.indexOf(searchText)
的返回值,可以基于是否为-1
(不匹配)来设置相应列表视图条目的CSS样式。
*Note: non-jQuery solution *注意:非jQuery解决方案
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.