emptyindorill,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
.parent {
float: left;
width: 100%;
margin: 0 0 10px;
background: green;
}
.child {
float: left;
width: 100%;
margin: 0 0 10px;
background: blue;
}
.subchild {
float: left;
width: 100%;
margin: 0 0 10px;
background: yellow;
height: 10px;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(function() {
$('.parent').each(function() {
var lvllenght = $('.child .subchild', this).length;
$('.counter', this).prepend("<span class=\"lvllenght\">" + lvllenght + "</span>");
});
});
</script>
</head>
<body>
<div class="parent">
<div class="opener">
<div class="counter"></div>
</div>
<div class="child">
<div class="subchild"></div>
<div class="subchild"></div>
<div class="subchild"></div>
<div class="subchild"></div>
<div class="subchild"></div>
</div>
</div>
<div class="parent">
<div class="opener">
<div class="counter"></div>
</div>
<div class="child">
<div class="subchild"></div>
<div class="subchild"></div>
<div class="subchild"></div>
</div>
</div>
<div class="parent">
<div class="opener">
<div class="counter"></div>
</div>
<div class="child">
<div class="subchild"></div>
<div class="subchild"></div>
<div class="subchild"></div>
<div class="subchild"></div>
<div class="subchild"></div>
<div class="subchild"></div>
<div class="subchild"></div>
<div class="subchild"></div>
</div>
</div>
</body>
</html>