jQuery UI Checkboxradio refresh() Method

jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library. Whether you are 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 jQuery Mobile Checkboxradio refresh() method. This method is used to refresh the Checkboxradio button widget. This method does not accept any parameters

Syntax:

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

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 jQuery UI Checkboxradio refresh() 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;">
            w3wiki
        </h1>
  
        <h3>jQuery UI Checkboxradio refresh() 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="Refresh CheckboxRadio" 
            style="padding: 8px">
          
        <script>
            $(document).ready(function () {
                $(".radio").checkboxradio();
                $("#btn").on('click', function() {
                    if($(".radio").checkboxradio("refresh"))
                        alert("Refresh the checkboxradio widget");
                })
            });
        </script>
    </center>
</body>
</html>


Output:

 

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