Sibling + selector does't work in IE7 when using jQuery

前端 未结 3 1280
野趣味
野趣味 2021-01-20 09:18

Trying to select a sibling element using jQuery and it doesn\'t work in IE7.

Here is my sample code: http://jsfiddle.net/y7AHz/6/ (click Run to see result)

3条回答
  •  萌比男神i
    2021-01-20 09:52

    This is a known bug with sizzle (the selector engine underneath jQuery) in IE6 and 7. Instead, use .next(), which is equivalent to the + or next adjacent selector, and .find(). It's more verbose, but it works in IE6+:

    var numberOfListItems = $("#txtInput").next(".ulContainer").find("li").length;
    

    Updated jsFiddle

提交回复
热议问题