📜  jQuery UI Resizable disable() 方法(1)

📅  最后修改于: 2023-12-03 15:16:44.906000             🧑  作者: Mango

jQuery UI Resizable disable() 方法

disable() 方法是 jQuery UI Resizable 的一个函数,用于禁用 resizable 功能。当调用此方法时,resizable 将被禁用,并且不能再被拖拽大小。该方法没有任何参数。

语法
$( ".selector" ).resizable( "disable" );
返回值

该方法没有返回值。

例子

以下示例演示如何使用 disable() 方法来禁用 resizable:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>jQuery UI Resizable disable() 方法</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.12.4.js"></script>
  <script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <style>
    #resizable {
      width: 150px;
      height: 150px;
      border: 1px solid black;
      background-color: #ccc;
    }
  </style>
  <script>
    $(function() {
      $( "#resizable" ).resizable();
      $( "#disable" ).click(function() {
        $( "#resizable" ).resizable( "disable" );
      });
    });
  </script>
</head>
<body>
 
<div id="resizable"></div>
<button id="disable">禁用 resizable</button>
 
</body>
</html>

在上面的示例中,当点击“禁用 resizable”按钮时,调用了 disable() 方法来禁用 resizable。您可以尝试拖拽大小并再次单击按钮来禁用 resizable。

总结

disable() 方法是一个简单但有用的 jQuery UI Resizable 函数,它允许您禁用 resizable 并阻止进一步拖拽大小。该方法没有任何参数,它可以通过调用以下方式来使用:

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