css - jquery selector: detect deviant class -


here's markup:

<div class='seat'></div> <div class='seat marked'></div> <div class='seat marked'></div> <div class='seat marked'></div> <div class='seat'></div> <div class='seat marked'></div> <div class='seat'></div> <div class='seat'></div> 

as simple binary optical translation be: -xxx-x--

what want determine if group/range of elements containing class "marked" has gap of @ least 1 element not have class "marked". ideas best approach?

thanks

if trying check if there gap , may following :

$('.marked').nextuntil(":not(.marked)").length == ($('.marked').length - 1) 

nextuntil give items in sequence while excluding .marked selector using :not operator.

example : https://jsfiddle.net/bneen5rc/2/

if trying find element :

var matchfound = false; var firstinstance = false; $('div').each(function() {    if($(this).hasclass('marked') && $(this).hasclass('seat'))    {       matchfound = true;       firstinstance = true;    }    else      matchfound = false;       if(!matchfound && firstinstance)      {        console.log("marked sequence changed");        return false;      }  }); 

example : https://jsfiddle.net/bneen5rc/3/