Open In App

jQWidgets jqxCheckBoxGroup val() Method

Last Updated : 30 Jan, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

jQWidgets is a JavaScript framework for making web-based applications for PC and mobile devices. It is a very powerful and optimized framework, platform-independent, and widely supported. The jqxCheckBoxGroup widget is used to display a group of checkboxes that allows users to select or deselect the checkbox group.

The val() method is used to set or return the value of the displayed jqxCheckBoxGroup. It returns [].

Syntax:

$("#jqxCheckBoxGroup").jqxCheckBoxGroup('val');

Parameters:

  • value: It is the specified value parameter that is optional in nature. It is of type [].

Linked Files: Download jQWidgets from the given link. In the HTML file, locate the script files in the downloaded folder.

<link rel=”stylesheet” href=”jqwidgets/styles/jqx.base.css” type=”text/css” />
<link rel=”stylesheet” href=”jqwidgets/styles/jqx.energyblue.css”>
<script type=”text/javascript” src=”scripts/jquery-1.11.1.min.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxcore.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxcheckbox.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxcheckboxgroup.js”></script>

Example 1: The below example illustrates the jQWidgets jqxCheckBoxGroup val() method.

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <link rel="stylesheet" href=
        "jqwidgets/styles/jqx.base.css" type="text/css" />
    <link rel="stylesheet" href=
        "jqwidgets/styles/jqx.energyblue.css">
    <script type="text/javascript"
        src="scripts/jquery-1.11.1.min.js"></script>
    <script type="text/javascript"
        src="jqwidgets/jqxcore.js"></script>
    <script type="text/javascript"
        src="jqwidgets/jqxcheckbox.js"></script>
    <script type="text/javascript"
        src="jqwidgets/jqxcheckboxgroup.js"></script>
    <script type="text/javascript"
        src="jqwidgets/jqxbuttons.js"></script>
      
    <style>
        body {
            margin-left: 100px;
        }
  
        .jqxcheckboxgroup {
            margin-left: 50px;
        }
    </style>
</head>
  
<body>
    <center>
        <h1 style="color: green;">
            GeeksforGeeks
        </h1>
  
        <h3>
            jQWidgets jqxCheckBoxGroup val() Method
        </h3>
  
        <h4>Select your Company name:</h4>
  
        <div class='jqxcheckboxgroup'>GfG</div>
        <div class='jqxcheckboxgroup'>TCS</div>
        <div class='jqxcheckboxgroup'>Capgemni</div>
        <div class='jqxcheckboxgroup'>Wipro</div>
        <br>
        <input type="button" style="margin: 5px;" 
               id="btn" value="Click here" />
        <div id="log"></div>
  
        <script type="text/javascript">
            $(document).ready(function () {
                $(".jqxcheckboxgroup").jqxCheckBox({
                    theme: 'energyblue',
                });
                $("#btn").jqxButton({
                    width: 180,
                    theme: 'energyblue',
                });
                $('#btn').jqxButton().
                    click(function () {
                        var v = $('.jqxcheckboxgroup').jqxCheckBox('val');
                        $('#log').text(v);
                    });
            });    
        </script>
    </center>
</body>
  
</html>


Output:

 

Example 2: The following is another example of the jqxCheckBoxGroup val() method in jQWidgets.

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <link rel="stylesheet" href=
        "jqwidgets/styles/jqx.base.css" type="text/css" />
    <link rel="stylesheet" href=
        "jqwidgets/styles/jqx.energyblue.css">
    <script type="text/javascript"
        src="scripts/jquery-1.11.1.min.js"></script>
    <script type="text/javascript"
        src="jqwidgets/jqxcore.js"></script>
    <script type="text/javascript"
        src="jqwidgets/jqxcheckbox.js"></script>
    <script type="text/javascript"
        src="jqwidgets/jqxcheckboxgroup.js"></script>
    <script type="text/javascript"
        src="jqwidgets/jqxbuttons.js"></script>
      
    <style>
        body {
            margin-left: 100px;
        }
  
        .jqxcheckboxgroup {
            margin-left: 50px;
        }
    </style>
</head>
  
<body>
    <center>
        <h1 style="color: green;">
            GeeksforGeeks
        </h1>
  
        <h3>
            jQWidgets jqxCheckBoxGroup val() Method
        </h3>
  
        <h4>Select your Company name:</h4>
  
        <div class='jqxcheckboxgroup'>GfG</div>
        <div class='jqxcheckboxgroup'>TCS</div>
        <div class='jqxcheckboxgroup'>Capgemni</div>
        <div class='jqxcheckboxgroup'>Wipro</div>
        <br>
        <input type="button" style="margin: 5px;" 
               id="btn" value="Click here" />
        <div id="log"></div>
  
        <script type="text/javascript">
            $(document).ready(function () {
                $(".jqxcheckboxgroup").jqxCheckBox({
                    theme: 'energyblue',
                });
                $("#btn").jqxButton({
                    width: 180,
                    theme: 'energyblue',
                });
                $('#btn').jqxButton().
                    click(function () {
                        var v = $('.jqxcheckboxgroup').jqxCheckBox('val');
                        if (v === null) {
                            $('#log').text("Null!");
                        }
                        else {
                            $('#log').text("Not null!");
                        }
                    });
            });
        </script>
    </center>
</body>
  
</html>


Output:

 

Reference: https://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxcheckboxgroup/jqxcheckboxgroup-api.htm?search=



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads