0

在 IE8 上,jQuery 版本 1.4.2 为以下选择器路径返回 0(当检查长度时),但对于 1.9.1 版本,它返回 1。

selectorPath = 'DIV#header + DIV > TABLE:first-child > TBODY:first-child > 
                TR:first-child > TD:first-child > TABLE:first-child > 
                TBODY:first-child > TR:first-child > TD:first-child > 
                TABLE:first-child > TBODY:first-child > TR:first-child > 
                TD:first-child > DIV:first-child + P + P + P + P + P + P 
                + P + P + P + P + P + P + P + P + P + P + P + P + P + P + 
                P + P + P + P + P + P + P + P + P + P + P + P + P + P + P 
                + P + P + P + P + P + P + H2 + P + P + P + P + P + P + P + 
                P + P';

$_1_4_2(selectorPath).length //returns 0

$_1_9_1(seelctorPath).length //returns 1

有人可以指出涵盖此问题的确切错误,或者至少列出 1.4.2 版本上可能相关的选择器路径错误

4

1 回答 1

0

试着把它分成几块..

selectorPath = 'DIV#header + DIV > TABLE:first-child > TBODY:first-child > 
                    TR:first-child > TD:first-child > TABLE:first-child > 
                    TBODY:first-child > TR:first-child > TD:first-child > 
                    TABLE:first-child > TBODY:first-child > TR:first-child > 
                    TD:first-child > DIV:first-child + P + P + P + P + P + P 
                    + P + P + P + P + P + P + P + P + P + P + P + P + P + P + 
                    P + P + P + P + P + P + P + P + P + P + P + P + P + P + P 
                    + P + P + P + P + P + P + H2 + P + P + P + P + P + P + P + 
                    P + P';

    var half_len = Math.floor(selectorPath.length/2)                
    var first_part = selectorPath.substring(0, half_len);
    var second_part = selectorPath.substring(half_len, selectorPath.length);

    $_1_4_2(first_part).filter(second_part).length  
于 2013-02-05T11:29:46.030 回答