How can I dynamically find elements with the same length of class names?
var className = $('.floor-4').attr('class').split(' ')[1];
var classLength = $('.' + className).length;
Here is the HTML code:
<div id="demo">
<div class="floor floor-1" data-floor="5" data-floor-sub="0">
<span class="text">Floor 1</span>
</div>
<div class="floor floor-2" data-floor="5" data-floor-sub="1">
<span class="text">Floor 2</span>
</div>
...
<div class="floor floor-5" data-floor="6" data-floor-sub="4">
<span class="text">Floor 5</span>
</div>
</div>