Open In App

jQuery UI Checkboxradio widget() Method

Last Updated : 14 May, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library. Whether you’re building highly interactive web applications, or you just need to add a date picker to a form control, jQuery UI is a perfect choice.

In this article, we will be using the jQueryUI Checkboxradio widget() method. This method returns the instance of the current jQueryUI widget element. This method does not accept any parameters.

Syntax:

$(".selector").checkboxradio("widget");

CDN Link: First, add jQuery UI CDN links inside the head section that is 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: In this example, we will describe how to use the Checkboxradio widget() method.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <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>
</head>
  
<body>
    <center>
        <h1 style="color:green;">
            GeeksforGeeks
        </h1>
  
        <h3>jQuery UI Checkboxradio widget() Method</h3>
  
        <label for="radio1">Button 1</label>
        <input type="radio" name="radio" id="radio1" class='radio'>
        <br>
  
        <label for="radio2">Button 2</label>
        <input type="radio" name="radio" id="radio2" class='radio'>
        <br>
  
        <label for="radio3">Button 3</label>
        <input type="radio" name="radio" id="radio3" class='radio'>
        <br><br>
  
        <input type="button" id="btn" value="CheckboxRadio Widget" 
            style="padding:8px">
          
        <script>
            $(document).ready(function () {
                $(".radio").checkboxradio();
                $("#btn").on('click', function() {
                    var gfg = $(".radio").checkboxradio("widget");
                    console.log(gfg);
                })
            });
        </script>
    </center>
</body>
</html>


Output:

 

Reference: https://api.jqueryui.com/checkboxradio/#method-widget



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

Similar Reads