jQuery UI菜单isLastItem()方法

jQuery UI菜单isLastItem()方法

jQuery UI由GUI部件、视觉效果和使用jQuery、CSS和HTML实现的主题组成。jQuery UI非常适合为网页构建UI界面。
jQuery UI isLastItem()方法用于检查菜单项是否是其最后一项,它相应地返回布尔值。

语法:

$(".selector").menu( "isLastItem" );

方法:首先,添加你的项目所需的jQuery UI脚本。

<link href = “https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css” rel = “stylesheet”>
<script src = “https://code.jquery.com/jquery-1.10.2.js”></script>
<script src = “https://code.jquery.com/ui/1.10.4/jquery-ui.js”></script>

例子:在这个例子中,我们将实现isLastItem()方法。

<!doctype html>
<html lang="en">
  
<head>
    <meta charset="utf-8">
    <link href=
"https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css"
        rel="stylesheet">
    <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
  
    <script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js">
    </script>
  
    <style>
        .ui-menu {
            width: 200px;
        }
    </style>
  
    <script>
        (function() {
            var menu =("#gfg").menu();
            ("#gfg").menu()
        });
  
        function chck() {
            var a =("#gfg").menu("isLastItem");
            console.log(a)
        }
    </script>
</head>
  
<body>
    <h1>jQuery UI | menu isLastItem method</h1>
    <ul id="gfg">
        <li><a href="#" onclick="chck()">Menu</a>
            <ul>
                <li><a href="#" onclick="chck()">
                    Submenu
                </a></li>
            </ul>
        </li>
        <li><a href="#" onclick="chck()">Menu</a>
            <ul>
                <li><a href="#" onclick="chck()">
                    Submenu
                </a></li>
                <li><a href="#" onclick="chck()">
                    Submenu
                </a></li>
            </ul>
        </li>
    </ul>
</body>
  
</html>

输出:在控制台我们可以看到每个菜单项对应的布尔值。

jQuery UI菜单isLastItem()方法

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程