I’m trying to make a function iterate through all doms with a class and apply diff rules depending on the class. I kinda know what, but don’t know how.
1.On load check input-c for class auc/fix (count input-c and iterate through each?)
2.if auc do this
3.if fix do that
4.end function
5.find next input-c - if none exit
6.repeat step 2-6
html like so
<div class="item-c rowview transition auc">container1</div>
<div class="item-c rowview transition fix">container2</div>
<div class="item-c rowview transition auc">container3</div>
<div class="item-c rowview transition fix">container4</div>
tried along the lines of
$(document).ready(function() {
$.each($(".input-c"), function() {
console.log('in');
if ($(".item-c").hasClass("fix")){
console.log('fix');
}
else if
($(".item-c").hasClass("auc")){
console.log('auc');
}
});
});
doesnt get as far as in!
without .each() … only the first container is checked and that rule is applied to all.
Suppose I need to cycle through all item-c and add count to an array then cycle through the array for each?
Help mucho appreciated