How to select a range of elements in jQuery

后端 未结 3 897
庸人自扰
庸人自扰 2020-11-28 08:57
... ... ... ... ...
3条回答
  •  生来不讨喜
    2020-11-28 09:32

    You should be able to do this by extracting a slice of the array thus. It's the line

    $("div[id='myDiv'] > a").slice(1,4).css("background","yellow");
    

    that you're interested in. It will affect the 2nd, 3rd and 4th elements.

    
        
            
            
        
        
            
    1 2 3 4 5 6

    Click here

提交回复
热议问题