【问题标题】:Handling radio buttons groups select event with JQuery UI使用 JQuery UI 处理单选按钮组选择事件
【发布时间】:2012-10-06 20:45:48
【问题描述】:

为什么 JQuery UI 选项按钮(按钮集)没有任何事件 - 我想为它处理选择事件,想知道这样做的正确方法是什么。

【问题讨论】:

    标签: jquery-ui jquery-ui-button


    【解决方案1】:

    您应该为单选按钮本身点击正常的change 事件。扩展 jQueryUI 网站上的示例:

    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);
    });
    

    buttonset 小部件只是以某种方式设置单选按钮的样式。所有常规事件都将按预期触发。

    示例: http://jsfiddle.net/andrewwhitaker/LcJGd/

    【讨论】:

    • 我明白了,我认为它会比仅仅编辑外观更进一步......
    猜你喜欢
    • 2022-01-13
    • 2011-10-26
    • 2020-03-11
    • 2011-02-13
    • 2013-08-16
    • 2018-05-15
    • 2019-04-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多