jquery-ui检索在一个按钮集(复选框)中选择的firefox问题

jquery-ui retrieving selected in a buttonset (checkbox) - firefox issue

本文关键字:复选框 选择 问题 firefox 一个 检索 jquery-ui 按钮      更新时间:2023-09-26

可以在jquery ui按钮集构建中使用复选框检索"选定"按钮(允许多选),并使用:

$('#format').buttonset();
$('#format').click(function() {
  var text = "";
  $('#format').find('label[aria-pressed|="true"]').each(function() {
      text += $(this).attr("for") + "-";
  });
  $('#selected').html(text); 
});

这在Chrome、IE、Safari中运行良好,但在Firefox中不考虑单击的复选框。你可以在jsFiddle中查看这个。

尝试:

$('label.ui-state-active')

查看我更新的jsFiddlehttp://jsfiddle.net/qLWNd/

尝试使用函数绑定

$('#format').bind("click",function() {
  var text = "";
  $('#format').find('label[aria-pressed|="true"]').each(function() {
      text += $(this).attr("for") + "-";
  });
  $('#selected').html(text); 
});

或者jquery 的实时插件

FYI,从jquery ui 1.10.0到1.11.4(最新版本),click()事件在Firefox中的复选框按钮集中无法正常工作。

尝试:

$('#format').change(function () {
    var text = "";
    $(this).children('label.ui-state-active').each(function () {
      text += $(this).attr("for") + "-";
    });
    $("#selected").html(text);
});

查看此jsFiddlehttp://jsfiddle.net/03ee1m60/2/