【发布时间】:2010-11-08 23:49:58
【问题描述】:
我是 jQuery 新手,我一直在尝试弄清楚如何使用 jQuery-ui Selectable 组件来替代一组复选框。
http://jqueryui.com/demos/selectable/
如果我能找到一种方法来隐藏复选框但仍显示其标签,我想我可以让它工作。 (我也不是 HTML 专家)。可以这样做吗?
【问题讨论】:
标签: jquery html checkbox jquery-ui-selectable
我是 jQuery 新手,我一直在尝试弄清楚如何使用 jQuery-ui Selectable 组件来替代一组复选框。
http://jqueryui.com/demos/selectable/
如果我能找到一种方法来隐藏复选框但仍显示其标签,我想我可以让它工作。 (我也不是 HTML 专家)。可以这样做吗?
【问题讨论】:
标签: jquery html checkbox jquery-ui-selectable
您可以为此使用selecting 和unselecting 事件,例如:
$( "#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 working 和 here's that same version with just some added styling to hide the checkboxes。
不过,如果您正在进行 AJAX 提交,check out the serialize demo 表明您可以从元素中获取任何值,但它不必是实际的输入元素。
【讨论】: