Open In App

jQuery UI Slider start Event

jQuery UI consists of GUI widgets, visual effects, and themes implemented using HTML, CSS, and jQuery. jQuery UI is great for building UI interfaces for the webpages. jQuery UI provides us a slider control through the slider widget.

The slider widget helps us to get a certain value using a given range. We can change the slider value by sliding. The start event is used to trigger when the user starts sliding the slider.



The Slider start Event accepts two values that are listed below:

Syntax:



Initialize the slider with the start callback:

$( ".selector" ).slider({
    start: function( event, ui ) {}
});

Bind an event listener to the slidestart event:

$( ".selector" ).on( 
    "slidestart", 
    function( event, ui ) {} 
);

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

<link rel=”stylesheet” href=”//code.jquery.com/ui/1.12.1/themes/smoothness/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>

Example: This example describes the jQuery UI Slider start Event.




<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <title>
        jQuery UI Slider start Event
    </title>
    <link rel="stylesheet" href=
"//code.jquery.com/ui/1.12.1/themes/smoothness/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>
        h1 {
            color: green;
        }
        #GFG {
            width: 600px;
        }
    </style>
</head>
<body>
    <center>
        <h1>GeeksforGeeks</h1>
        <h2>jQuery UI Slider start Event</h2>
        <div id="GFG"></div>
    </center>
    <script>
        $(function () {
            $("#GFG").slider();
            $("#GFG").on('slidestart', function () {
                alert('Slider Start Event Triggered!');
            })
        });
    </script>
</body>
</html>

Output:

 

Reference: https://api.jqueryui.com/slider/#event-start


Article Tags :