jQuery Mobile filterable children选项

jQuery Mobile filterable children选项

jQuery UI是一种基于网络的技术,由各种GUI部件、视觉效果和主题组成。这些功能可以通过jQuery JavaScript库来实现。jQuery UI是为网页建立UI界面的最佳工具。它也可以用来建立高度互动的网络应用程序,或者可以用来轻松添加小工具。

在这篇文章中,我们将学习jQuery Mobile中的可过滤的children选项。禁用选项提供了在过滤过程中会被处理的儿童列表。

以下是该选项所支持的多种类型。

  • String。这种类型是一个jQuery选择器,将被用来从元素的孩子中选择。
  • jQuery。这个类型是一个jQuery对象,包含要过滤的元素列表。
  • Function。这种类型是一个函数,它返回一个jQuery对象,包含要过滤的元素的列表。每当需要进行过滤的时候,它也会被调用,没有参数。
  • Element。这种类型是一个DOM元素,它是过滤器的一个琐碎的应用。

语法:

children选项需要一个上述定义的数值类型,语法如下。

$( ".selector" ).filterable({ children: ".my-children" });
  • 获得children选项。
var children = $( ".selector" ).filterable( "option", "children" );  
  • 设置children选项。
$( ".selector" ).filterable( "option", "children", ".my-children");

CDN链接:添加这些jQuery Mobile脚本,这将是你的项目所需要的。

<link rel=”stylesheet” href=”https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css” />
<script src=”http://code.jquery.com/jquery-1.11.0.min.js”></script>
<script src=”https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js”></script>

例子:这个例子演示了jQuery Mobile可过滤children选项

<!DOCTYPE html>
<html lang="en">        
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1">
    <link rel="stylesheet"
          href=
"https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
    <script src=
"http://code.jquery.com/jquery-1.11.0.min.js">
    </script>
    <script src=
"https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js">
    </script>    
          
    <script>
        (document).ready(function () {
          
            (".items").filterable({});
            (".btnclass").bind("click", function () {
                var children =( ".items" )
                    .filterable( "option", "children" );
                $("#divID").html("<b>List of Children:" 
                    + "<br>" + children + "</b>"
                );
            });
        });
    </script>
</head>
<body>
    <center>
        <div data-role="page" id="page1">
            <div>
                <h1 style="color:green;">GeeksforGeeks</h1>
                <h3>
                    jQuery Mobile Filterable children Option
                </h3>
            </div>    
            <div role="main" class="ui-content">
                <div >
                    <ul class="items" style="list-style-type:none;">
                        <li>
                            <a href="https://www.geeksforgeeks.org/data-structures"
                            target="_blank">
                                Data Structures
                            </a>
                        </li>
                        <li>
<a href="https://practice.geeksforgeeks.org/courses/complete-interview-preparation"
                            target="_blank">
                                Interview preparation
                            </a>
                        </li>
                        <li>
                            <a href="https://www.geeksforgeeks.org/java"
                            target="_blank">
                                Java Programming
                            </a>
                        </li>
                    </ul>
                </div>
            </div>    
            <input type="button" Value="Children Option"
                class="btnclass" />
            <br>
            <div id="divID"></div>
        </div>
    </center>
</body>
</html>

输出:

jQuery Mobile filterable children选项

jQuery Mobile filterable children选项

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程