当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


jQWidgets jqxRadioButtonGroup val()用法及代码示例


jQWidgets是一个 JavaScript 框架,用于为 PC 和移动设备制作基于 Web 的应用程序。它是一个非常强大、经过优化、平台无关且得到广泛支持的框架。jqxRadioButtonGroupwidget用于显示一组单选按钮,这些单选按钮拥有API以便对其进行修改。

val()方法用于设置或返回显示的jqxRadioButtonGroup的值。它没有参数,也不返回任何内容。

用法:

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

链接文件:下载jQWidgets从给定的链接。在 HTML 文件中,找到下载文件夹中的脚本文件。

<link rel=”stylesheet” href=”jqwidgets/styles/jcustomize qx.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/jqxradiobutton.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxradiobuttongroup.js”></script>

示例 1:下面的示例说明了 jQWidgets jqxRadioButtonGroupval()方法。

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/jqxradiobutton.js"></script> 
    <script type="text/javascript"
        src="jqwidgets/jqxradiobuttongroup.js"></script> 
    <script type="text/javascript"
        src="jqwidgets/jqxbuttons.js"></script> 
      
    <style> 
        body { 
            margin-left: 100px; 
        } 
  
        .jqxradiobuttongroup { 
            margin-left: 50px; 
        } 
    </style> 
</head> 
  
<body> 
    <center> 
        <h1 style="color: green;"> 
            GeeksforGeeks 
        </h1> 
  
        <h3> 
            jQWidgets jqxRadioButtonGroup val() Method 
        </h3> 
  
        <h4>Choose the correct option:</h4> 
  
        <div class='jqxradiobuttongroup'> 
            GeeksforGeeks is a service oriented company. 
        </div> 
        <div class='jqxradiobuttongroup'> 
            Capgemni is not a service oriented company. 
        </div> 
        <div class='jqxradiobuttongroup'> 
            Microsoft is not a service oriented company. 
        </div> 
        <br> 
        <input type="button" style="margin: 5px;" 
               id="btn" value="Click here" /> 
        <div id="log"></div> 
  
        <script type="text/javascript"> 
            $(document).ready(function () { 
                $(".jqxradiobuttongroup").jqxRadioButton({ 
                    theme: 'energyblue', 
                }); 
                $("#btn").jqxButton({ 
                    width: 180, 
                    theme: 'energyblue', 
                }); 
                $('#btn').jqxButton(). 
                    click(function () { 
                        var v = 
                            $('.jqxradiobuttongroup').jqxRadioButton('val'); 
                        $('#log').text(v); 
                    }); 
            });     
        </script> 
    </center> 
</body> 
  
</html>

输出:

示例 2:下面是jqxRadioButtonGroup的另一个例子val()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/jqxradiobutton.js"></script> 
    <script type="text/javascript"
        src="jqwidgets/jqxradiobuttongroup.js"></script> 
    <script type="text/javascript"
        src="jqwidgets/jqxbuttons.js"></script> 
      
    <style> 
        body { 
            margin-left: 100px; 
        } 
  
        .jqxradiobuttongroup { 
            margin-left: 50px; 
        } 
    </style> 
</head> 
  
<body> 
    <center> 
        <h1 style="color: green;"> 
            GeeksforGeeks 
        </h1> 
  
        <h3> 
            jQWidgets jqxRadioButtonGroup val() Method 
        </h3> 
  
        <h4>Choose the correct option:</h4> 
  
        <div class='jqxradiobuttongroup'> 
            GeeksforGeeks is a service oriented company. 
        </div> 
        <div class='jqxradiobuttongroup'> 
            Capgemni is not a service oriented company. 
        </div> 
        <div class='jqxradiobuttongroup'> 
            Microsoft is not a service oriented company. 
        </div> 
        <br> 
        <input type="button" style="margin: 5px;" 
               id="btn" value="Click here" /> 
        <div id="log"></div> 
  
        <script type="text/javascript"> 
            $(document).ready(function () { 
                $(".jqxradiobuttongroup").jqxRadioButton({ 
                    theme: 'energyblue', 
                }); 
                $("#btn").jqxButton({ 
                    width: 180, 
                    theme: 'energyblue', 
                }); 
                $('#btn').jqxButton(). 
                    click(function () { 
                        var v = $('.jqxradiobuttongroup').jqxRadioButton('val'); 
                        if (v === null) { 
                            $('#log').text("Null!"); 
                        } 
                        else { 
                            $('#log').text("Not null!"); 
                        } 
                    }); 
            }); 
        </script> 
    </center> 
</body> 
  
</html>

输出:

参考: https://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxradiobuttongroup/jqxradiobuttongroup-api.htm?search=



相关用法


注:本文由纯净天空筛选整理自nidhi1352singh大神的英文原创作品 jQWidgets jqxRadioButtonGroup val() Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。