Jquery stops before for loop -


i trying adjust div font-size depending on height

i elements class "prod-name" .each

 $prod_names = new array();      $i=0;      $j=0;        $(".prod-name").each(function(){         $prod_names[$i] = $(this);         $i++;      });        for($j=0;$j>=$i;$j++){          console.log("in for");      if(($prod_names[$j].height() > 20) && ($prod_names[$j].height() <= 40)){          console.log("ok");          $prod_names[$j].css("font-size","0.9em");      }else if($prod_names[$j].height() > 40){          $prod_names[$j].css("font-size","0.8em");      }      }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>  <div id="mostviewed" class="products">      <h2 class="cat-title">most viewed</h2>      <ul>          <li class="scol25  mcol25 lcol25" >              <a href="product.php" class="prod-img"><img src="images/products/.jpg" title=""/></a>              <p class="prod-name">intel core i3</p>              <div class="prices">                  <p id="original-price" class="scol50 mcol50 lcol50 price">&euro;</p>                  <p id="low-price" class="scol50 mcol50 lcol50 price">&euro;</p>              </div>              <div class="fa-buttons">                  <a id="morea" class="scol50 mcol50 lcol50 add1"  title="more information" href="product.php"><i class="fa fa-search" aria-hidden="true"></i></a>                  <a id="fava" href="#" class="scol50 mcol50 lcol50 add1" title="add favorites"><i class="fa fa-heart" aria-hidden="true" ></i></a>              </div>          </li>      </ul>  </div>

i added logs see if reaches code in loop , doesnt

note: in reality use php better understanding of problem changed html

thank you

you have problem logic here... assuming there 4 prod-name elements, $i 4, while $j 0, $j>=$i false hence won't in loop..

i bet shall reconsider aim of code , write in neater way.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -