在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上可能相关的选择器路径错误的列表
答案 0 :(得分: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