jQuery UI Widgets Forums Editors Button, RepeatButton, ToggleButton, LinkButton How jqxSwitchButton get value in jquery?

This topic contains 1 reply, has 2 voices, and was last updated by  Hristo 8 years, 7 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • How jqxSwitchButton get value in jquery? #80624

    mytim
    Participant

    How can I get and set jqxSwitchButton value? I use this code to create a switch button,and want to get the Button value.But it did not work.

    <meta charset=”UTF-8″>
    <title>SwitchButton</title>
    <link rel=”stylesheet” href=”style/style_edit.css” type=”text/css”>
    <link rel=”stylesheet” href=”js/jquery-ui-1.11.4.custom/jquery-ui.css”>
    <link rel=”stylesheet” href=”js/jquery-ui-1.11.4.custom/external/jqwidgets/styles/jqx.base.css” type=”text/css”/>
    <link rel=”stylesheet” href=”js/jquery-ui-1.11.4.custom/external/jqwidgets/styles/jqx.classic.css” type=”text/css”/>
    <script type=”text/javascript” src=”js/jquery-ui-1.11.4.custom/external/jquery/jquery-2.1.4.min.js”></script>
    <script src=”js/jquery-ui-1.11.4.custom/jquery-ui.js”></script>
    <script type=”text/javascript” src=”js/jquery-ui-1.11.4.custom/external/jqwidgets/jqxcore.js”></script>
    <script type=”text/javascript” src=”js/jquery-ui-1.11.4.custom/external/jqwidgets/jqxswitchbutton.js”></script>
    <script type=”text/javascript” src=”js/jquery-ui-1.11.4.custom/external/jqwidgets/jqxcheckbox.js”></script>

    <script type=”text/javascript”>
    $(document).ready(function () {
    $(‘#jqxSwitchButton’).jqxSwitchButton({checked: true});
    // Get the value.
    var value = $(“#jqxSwitchButton”).jqxSwitchButton(‘val’,true);
    var value2 = $(“#jqxSwitchButton”).val();
    console.log(value);
    console.log(value2);

    // Set value.
    $(“#jqxSwitchButton”).jqxSwitchButton(‘val’, true);
    // Set value using jQuery’s val().
    $(“#jqxSwitchButton”).val(true);

    });
    </script>

    HTML:

    <div class=”switch_options”>
    <div id=”jqxSwitchButton” value=”A”></div>
    </div>
    it return two Boolean “true”,like the doc say: Parameter Type value(optional) Boolean Return Value Boolean How can I get the value “A”? means return String,then set the value. Thank you !

    How jqxSwitchButton get value in jquery? #80672

    Hristo
    Participant

    Hello mytim,

    To change the content of the Switch button you could use those properties – onLabel and offLabel.
    $('#jqxSwitchButton').jqxSwitchButton({ onLabel: 'TURN ON' }); From ‘ON’ to ‘TURN ON’.
    To get value of the onLabel could use – var onLabel = $('#jqxSwitchButton').jqxSwitchButton('onLabel');
    val is a method that could use to change current state of the SwitchButton of ‘ON’ or ‘OFF’. Could set only true or false.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.