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

前端 未结 3 1908
后悔当初
后悔当初 2021-01-20 09:08

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条回答
  •  孤街浪徒
    2021-01-20 09:58

    This will also work in IE7:

    var foo= $("#txtInput + ul.ulContainer");
    var numberOfListItems = $('li', foo).length;
    
     $("#output").text(numberOfListItems);
    

    Not sure which of the proposed fixes performs best, if it matters...

提交回复
热议问题