Skip to content
Related Articles

Related Articles Sliders setDisabled Option
  • Last Updated : 20 Dec, 2020

The library is a cross-browser library that aims at improving the user interface of a website. The Slider controls are thin tracks that allow the user to input values. It is done by defining a range of values that can be selected by the user by dragging the handle to the appropriate value.

The Sliders setDisabled function is used to disable the given slider. A slider that is enabled has its disabled property set to false and can be interacted with by the user. Using this function sets the disabled property to true and prevents the user to interact with the slider.



Parameters: This function has no parameters.



<!DOCTYPE html>
    <!-- Include the required scripts -->
    <script type="text/javascript" 
    <script type="text/javascript" 
        src="scriptaculous.js?load = slider">
    <!-- Style the Sliders so that they
        are properly visible -->
    <style type="text/css">
        .track {
            width: 250px;
            background-color: gray;
            height: 5px;
            position: relative;
        .track .handle {
            width: 20px;
            height: 10px;
            background-color: green;
            cursor: move;
            position: absolute;
            top: -2px;
        .pad {
            padding: 25px;
    <h1 style="color: green;">
    <h2>Sliders setDisabled</h2>
        An enabled slider can be disabled 
        by using the setDisabled() method 
        as shown below.
    <div class="pad">
        <div id="track-hor" class="track">
            <div id="handle-hor" class="handle">
    <p>Current Slider 1 Value:
        <span id="out">0</span>
    <div class="pad">
        <div id="track-hor2" class="track">
            <div id="handle-hor2" class="handle">
    <button onclick="disableSlider()">
        Disable Second Slider
    <p>Current Slider 2 Value:
        <span id="out2">0</span>
    <script type="text/javascript">
        // Initialize the slider
        let slider = new Control.Slider('handle-hor',
            'track-hor', {
            // Define the range
            range: $R(1, 100),
            onSlide: (val) => {
                    .textContent = val;
        let slider2 = new Control.Slider('handle-hor2',
            'track-hor2', {
            // Define the range
            range: $R(1, 100),
            onSlide: (val) => {
                    .textContent = val;
        function disableSlider() {
            // Set the value of the slider
            // to the given value



My Personal Notes arrow_drop_up
Recommended Articles
Page :