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

前端 未结 3 1293
野趣味
野趣味 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条回答
  •  长情又很酷
    2021-01-20 09:51

    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...

提交回复
热议问题