3

I need to implement search functionality in my app(same as note pad control F).I have group of data i need to search whether it present on not .Data is not in list view .it in like we write some thing in note pad then we search on any work.Is this possible.? can you please tell me how to do.? please provide some example.

4

1 回答 1

2

也许你可以使用window.find(aString, aCaseSensitive, aBackwards, aWrapAround, aWholeWord, aSearchInFrames, aShowDialog)

  • aString:要搜索的文本字符串。
  • aCaseSensitive:布尔值。如果为 true,则指定区分大小写的搜索。
  • aBackwards:布尔值。如果为真,则指定向后搜索。
  • aWrapAround:布尔值。如果为真,则指定环绕搜索。
  • aWholeWord:布尔值。如果为真,则指定整个单词搜索。
  • aSearchInFrames:布尔值。如果为真,则指定以帧为单位的搜索。
  • aShowDialog :布尔值。如果为真,则指定一个显示对话框。


例子:

<!DOCTYPE html>
<html>

    <head>
        <title>jQuery Mobile Nested List</title>
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
        <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
        <script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
        <script type="text/javascript">
        function findText (str) 
        {
            if (str === "") {
                alert ("Please enter some text to search!");
                return;
            }

            if (window.find) {
                window.find (str, false, false, true, false, true, false);
            }
        }

        $(document).on('click', '#search', function () {
            findText("blah");
        });
    </script>
    </head>

    <body>
        <div id="list-page" data-role="page">
            <div data-role="header">
                 <h1>Find Page</h1>

            </div>
            <div data-role="content">
                <label for="search-field">Text Input:</label>
                <p> blah this is a test blah this is a test blah</p>
                <input type="button" name="search" id="search" value="Search"/>
            </div> 
        </div>
    </body>

</html>
于 2013-06-22T12:21:17.943 回答