How do you check the number of div blocks in the div block?
-
I'm using the jQuery Masonry library for the gallery. However, there is a centralization of the first line.
top:0; left:0;
If you put it in the center, all the other photos will go the same way. How do you write a test on js / jQuery, if div 1 (one), then use the styles that will level it down the center?<div style="position:relative; min-width:80%; clear:both; height:auto; margin:0 auto; padding-top:2%;padding-bottom:16%;"> <div class="grid"> <div class="grid-sizer"></div> <div class="grid-item marg_center"> <a class="example-image-link" href="http://timworld.info/wp-content/uploads/2016/05/Bauhaus_in_Tel_Aviv_7_120x80.jpg" data-lightbox="example-set" > <img class="example-image" src="http://timworld.info/wp-content/uploads/2016/05/Bauhaus_in_Tel_Aviv_7_120x80.jpg" alt=""/> </a> </div> </div> </div>
-
Use the function.
element.childNodes.length
♪ If he returns 0, there are no blocks in the block, and then you're using the necessary styles.