如何禁用一个jQuery UI菜单

如何禁用一个jQuery UI菜单

在这篇文章中,我们将禁用一个jQuery UI菜单

语法:

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

了解更多关于jQuery中的选择器和菜单选项。

步骤:

  • 首先,添加你的项目所需的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>

示例 1:

<!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 () {
                ("#gfg").menu();
                $("#gfg").menu("disable");
            });
        </script>
    </head>
  
    <body>
        <h1>jQuery UI | disable menu</h1>
        <ul id="gfg">
            <li><a href="https://www.geeksforgeeks.org/">1st</a>
          </li>
            <li><a href="https://www.geeksforgeeks.org/">2nd</a>
          </li>
            <li><a href="https://www.geeksforgeeks.org/">3rd</a>
          </li>
            <li><a href="https://www.geeksforgeeks.org/">2th</a>
          </li>
            <li><a href="https://www.geeksforgeeks.org/">5th</a>
          </li>
        </ul>
    </body>
</html>

输出:

如何禁用一个jQuery UI菜单?

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程