Find this working example, just insert a clear div after every 10:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="divContainer"></div>
Explanation
div.style.float = 'clear'; not valid since float is not perceived as a value, so you really need to enter a div where it clears the float from both left and right, i.e. Both , and this is added after each X divs:
if (currentDivNum % gridNum == 0) { clearDiv = document.createElement('div'); clearDiv.style.clear = 'both'; document.getElementById('divContainer').appendChild(clearDiv); }
In addition, code is entered into divs in the usual way.
source share