Open In App

jQuery UI Slider disabled Option

Last Updated : 02 Mar, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

jQuery UI consists of GUI widgets, visual effects, and themes implemented using jQuery, CSS, and HTML. jQuery UI is great for building UI interfaces for the webpages. jQuery UI provides us a slider control through the slider widget. Slider helps us to get a certain value using a given range. In this article we will see how to disable a slider. The disabled option when set to true will disable the slider.

Syntax:

$(".selector").slider(
   { disabled : true }
);

Parameters: This option accepts one parameter as discussed below:

  • boolean: If set to true, the slider will be disabled. By default, the value is false.

CDN Link: First, add jQuery UI scripts needed for your project.

<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>

Example 1: In this example, we will be using the boolean value as true.

HTML




<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <link href=
      rel="stylesheet"/>
    <script src=
    </script>
    <script src=
    </script>
  
    <script>
      $(function () {
        $("#gfg").slider({ disabled: true });
      });
    </script>
  </head>
  
  <body>
    <h1>GeeksforGeeks</h1>
    <h2>jQuery UI | slider disabled option</h2>
    <div id="gfg"></div>
  </body>
</html>


Output:

Example 2: In this example, we will be using the boolean value as false

HTML




<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <link href=
      rel="stylesheet"/>
    <script src=
    </script>
    <script src=
    </script>
    <script>
      $(function () {
        $("#gfg").slider({ disabled: false });
      });
    </script>
  </head>
  
  <body>
    <h1>GeeksforGeeks</h1>
    <h2>jQuery UI | slider disabled option</h2>
    <div id="gfg"></div>
  </body>
</html>


Output:

Reference: https://api.jqueryui.com/slider/#option-disabled



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads