如何防止 iCheck 对某些复选框进行样式设置,同时仍然对其他复选框进行样式设置?

How can I prevent iCheck from styling certain checkboxes, while still styling others?

我刚刚将 iCheck (http://icheck.fronteed.com) 合并到我的网站中,以便用 iCheck 提供的更具视觉吸引力的复选框样式替换页面上乏味的默认复选框元素。

iCheck 在大多数情况下工作得非常好,但出于某种原因,它破坏了我用于 tablesorter 的列选择器小部件 (https://mottie.github.io/tablesorter/docs/example-widget-column-selector.html) 的功能。

为了解决这个问题,我喜欢使用 iCheck 为我网站上的每个复选框设置样式,但属于列选择器小部件的任何复选框除外。有没有办法让 iCheck 忽略特定的 div 或复选框(通过添加 class),或者只使用标有特定 class 的 iCheck 样式复选框?

提前感谢您可能提出的任何建议!

我假设您想要设置样式和不想设置样式的复选框会有不同的 classes。如果不是,请在不应设置样式的复选框中添加额外的 class。

例如:

<input type="checkbox" />
<input type="checkbox" class="dont-style" />

//Adding not to the query selector only selects input's without the *dont-style* class
$('input').not('.dont-style').iCheck({
  labelHover: false,
  cursor: true
});

或者你可以只添加一个 class 到你想要设置样式的复选框,例如 styleMe 然后像这样初始化插件:

$('.styleMe').iCheck({
      labelHover: false,
      cursor: true
    });