Handling Switch Groups Selects an Event Using JQuery UI

why buttons JQuery UI (buttonset) do not have any events - I want to process the selected events for it, wonder how to do it right.

+6
source share
1 answer

You just need to push the regular change event for the switches themselves. Extension in the example on jQueryUI website:

Html:

 <div id="radio"> <input type="radio" id="radio1" name="radio" value="1" /><label for="radio1">Choice 1</label> <input type="radio" id="radio2" name="radio" value="2" checked="checked" /><label for="radio2">Choice 2</label> <input type="radio" id="radio3" name="radio" value="3" /><label for="radio3">Choice 3</label> </div> 

JavaScript:

 $("#radio").buttonset(); $("input[name='radio']").on("change", function () { alert(this.value); }); 

The buttonset widget is just the style of the radio buttons. All regular events will fire as expected.

Example: http://jsfiddle.net/andrewwhitaker/LcJGd/

+12
source

Source: https://habr.com/ru/post/927112/


All Articles