jquery - Adding classes to subchildren with addClass -
i trying add class 'animated fadeindown" subchildren of h1, letters individually fade in top instead of doing @ once. reason cannot type these classes in hand because using lettering.js, breaks "lorem ips" constituents when doc loads.
<h1 id = "letters"> <span class="char1">l</span> <span class="char2">o</span> <span class="char3">r</span> <span class="char4">e</span> <span class="char5">m</span> <span class="char6"> </span> <span class="char7">i</span> <span class="char8">p</span> <span class="char9">s</span> </h1>
my jquery:
$(document).ready(function() { $("#letters").children().addclass('animated fadeindown'); });
in fact, ideally, first 5 have class applied rather on of them.
$(document).ready(function() { $("#letters").find('span:lt(5)').addclass('animated fadeindown'); });
.animated{color:red}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <h1 id = "letters"> <span class="char1">l</span> <span class="char2">o</span> <span class="char3">r</span> <span class="char4">e</span> <span class="char5">m</span> <span class="char6"> </span> <span class="char7">i</span> <span class="char8">p</span> <span class="char9">s</span> </h1>
- use :lt()
description: select elements @ index less index within matched set
Comments
Post a Comment