$(function() { var fl = $('ul img:nth-child(3n+3)').height(); var fr = $('ul img:nth-child(3n+4)').height(); var result = fl += fr; if (result == 1092) { $('ul img:nth-child(3n+3)').addClass('landscape'); $('ul img:nth-child(3n+4)').addClass('landscape-2'); } else if (result == 2460) { $('ul img:nth-child(3n+3)').addClass('portrait'); $('ul img:nth-child(3n+4)').addClass('portrait-2'); } else if (result == 1776) { $('ul img:nth-child(3n+3)').addClass('landscape-portrait'); $('ul img:nth-child(3n+4)').addClass('landscape-portrait-2'); } });
<ul> <img height="546" src="images/landscape2.jpg"> <img height="1230" src="images/portrait.jpg"> <img height="1230" src="images/portrait.jpg" class="landscape-portrait"> <img height="546" src="images/landscape2.jpg" class="landscape-portrait-2"> <img height="546" src="images/landscape2.jpg"> <img height="1230" src="images/portrait.jpg" class="landscape-portrait"> <img height="1230" src="images/portrait.jpg" class="landscape-portrait-2"> <img height="1230" src="images/portrait.jpg"> <img height="546" src="images/landscape2.jpg" class="landscape-portrait"> <img height="546" src="images/landscape2.jpg" class="landscape-portrait-2"> <img height="546" src="images/landscape2.jpg"> </ul>
an+b - 1
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)