Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery: select all siblings with css left:position greater than left:position of an element

How to select all siblings of an element that are positioned to the right of it via css? fiddle link

like image 802
Brainache Avatar asked Oct 09 '22 06:10

Brainache


1 Answers

You can use filter() to return a subset of a selector based on a function you provide, try this:

var threeLeft = $("#three").position().left;
var $lis = $("ul li").filter(function() {
    return $(this).position().left > threeLeft;
});
$lis.css("border", "1px solid #C00");

Example fiddle

like image 104
Rory McCrossan Avatar answered Oct 12 '22 19:10

Rory McCrossan