我可以使用什么来代替:indeterminate jQuery选择器,以避免IE 8中出现异常?

Kut*_*ith 5 jquery internet-explorer-8

我有这样的代码

if ($('#chkCheckAll').is(':indeterminate') == true) 
{
}
Run Code Online (Sandbox Code Playgroud)

但是它在IE 8中抛出异常

在jQuery中可以做什么代替IE8

rai*_*7ow 3

使用这个代替:

var $allChk = $('#chkCheckAll');
if ($allChk[0] && $allChk[0].indeterminate ) {
  ... 
}
Run Code Online (Sandbox Code Playgroud)

问题是 IE8querySelectorAll实现不支持 ':inminated' 伪表达式。但在你的情况下,实际上不需要使用它,因为你可以查询 DOM 元素本身的相应属性