var x = 50;
I need to select the first card
which has offset().left
greater than x
$('.card').each(function(){
if ($(this).offset().left > x) {...}
});
So how to reduce the above to the first element matched?
var x = 50;
I need to select the first card
which has offset().left
greater than x
$('.card').each(function(){
if ($(this).offset().left > x) {...}
});
So how to reduce the above to the first element matched?
You can do this using jQuery's filter function
Something like
var x=50;
var first=$('.card').filter(()=>{
return $(this).offset().left>x;
}).first();
should give you the first element matching your requirements.