复选框未在 Firefox 中显示

checkbox is not displaying in firefox

本文关键字:显示 Firefox 复选框      更新时间:2023-09-26

我想在按钮单击事件上动态显示复选框。我写的代码是这样的

 $("button").on('click',function(){
  $(".chkbx").each(function(){
       $(this).show(); 
  });
 });

 $("#treeview").kendoTreeView({                                        
        checkboxes: {
               checkChildren: true,
               template: " # if(item.categoryid == 0){ }  else { #  <input type='checkbox'  id='#= item.haschildren #-#= item.categoryid #'  name='chkbox' class='chkbx' />#}#"
          },    
          dataSource: initial,
          dataTextField: ["categoryname"]                      
  });

这段代码在Chrome中工作,但在Firefox中不起作用。

尝试使用 jQuery 的普通 click() 函数。没有必要处理每个函数,元素上的 show() 就足够了。
这里有一个例子:jsFiddle。

编辑
你的代码实际上只适用于火狐、铬和 IE。虽然你可能会发现小提琴很有用。