jQWidgets jqxButtonGroup selected Event
jQWidgets is a JavaScript framework for making web-based applications for PC and mobile devices. It is a very powerful, optimized, platform-independent, and widely supported framework. The jqxButtonGroup is used to illustrate a jQuery widget that generates a group of buttons which functions like a normal buttons, radio buttons or checkboxes.
The selected event is activated whenever the displayed jqxButtonGroup is selected and the mode of selection must be either checkbox or radio.
Syntax:
$('#jqxButtonGroup').on('selected', function () {});
Linked Files: Download jQWidgets from the 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” />
<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/jqxbuttons.js”></script>
The below example illustrates the jqxButtonGroup selected event in jQWidgets.
Example:
HTML
<!DOCTYPE html> < html lang = "en" > < head > < link rel = "stylesheet" href = "jqwidgets/styles/jqx.base.css" type = "text/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/jqxbuttons.js" ></ script > </ head > < body > < center > < h1 style = "color: green" >GeeksforGeeks</ h1 > < h3 >jQWidgets jqxButtonGroup selected event</ h3 > < br /> < div id = "jqxBG" > < button style = "padding: 6px 36px" id = "l" >1st</ button > < button style = "padding: 6px 36px" id = "c" >2nd</ button > < button style = "padding: 6px 36px" id = "r" >3rd</ button > </ div > </ center > < div id = "log" ></ div > < script type = "text/javascript" > $(document).ready(function () { $("#jqxBG").jqxButtonGroup({ mode: "radio", }); $("#jqxBG").on("selected", function (event) { $("#log").html( "Button with index " + event.args.index + " is selected!" ); }); }); </ script > </ body > </ html > |
Output: