【问题标题】:How to hide an HTML checkbox but still show its label如何隐藏 HTML 复选框但仍显示其标签
【发布时间】:2010-11-08 23:49:58
【问题描述】:

我是 jQuery 新手,我一直在尝试弄清楚如何使用 jQuery-ui Selectable 组件来替代一组复选框。

http://jqueryui.com/demos/selectable/

如果我能找到一种方法来隐藏复选框但仍显示其标签,我想我可以让它工作。 (我也不是 HTML 专家)。可以这样做吗?

【问题讨论】:

    标签: jquery html checkbox jquery-ui-selectable


    【解决方案1】:

    您可以为此使用selectingunselecting 事件,例如:

    $( "#selectable" ).selectable({
        selecting: function(event, ui) {
            $(ui.selecting).find(':checkbox').attr('checked', true);
        },
        unselecting: function(event, ui) {
            $(ui.unselecting).find(':checkbox').attr('checked', false);
        }
    });
    

    You can test it here, with the checkboxes visible to see it workinghere's that same version with just some added styling to hide the checkboxes

    不过,如果您正在进行 AJAX 提交,check out the serialize demo 表明您可以从元素中获取任何值,但它不必是实际的输入元素。

    【讨论】:

    • 嗨尼克,太棒了,这正是我希望能够做到的。非常感谢。
    猜你喜欢
    • 2016-01-07
    • 1970-01-01
    • 2023-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-09
    相关资源
    最近更新 更多