I'm trying to get at the first not(.hidden) div after the .focus div. In this example the focus is X2, and I should get back X5, skipping X3 and X4 because they are hidden.
<div id='CONTAINER'>
<div id='X1'>eks1</div>
<div id='X2' class='focus'>eks2</div>
<div id='X3' class='hidden'>eks3</div>
<div id='X4' class='hidden'>eks4</div>
<div id='X5'>eks5</div>
<div id='X6'>eks6</div>
</div>
This seems like it should be a pretty simple jquery question, but I'm fairly new to this stuff.
The below statement should solve your problem.
$("#CONTAINER").find("div.focus").nextAll("div").not(".hidden").first();
Use the nextAll method:
http://api.jquery.com/next/
$('div.focus').nextAll('div:not(.hidden)').filter(':first');
This will find the next div after .focus that is not .hidden
try this!
$("#CONTAINER").find("div.focus").next('div[class!="hidden"]')
$nextNotHidden = $('.focus').nextUntil(':not(.hidden)').last().next()
Try this:
var stop = true;
$('#CONTAINER> div.focus +div').each(function(){
if(!$(this).hasClass('hidden') && stop) code
else stop = false;
});