Looping through set classes
I have 3 columns of divs that are inline and forms many lines:
- <div class="info0..."></div><div class="info1..."></div><div class="info2..."></div>
- ... repeat sim. line ...
I am trying to target the first and last lines of each class and change their borders.
- var str1 = 'info';
- for (i = 0; i < %id=infogroups%; i++) {
- console.log('Groups: ' + %id=infogroups%); // should always output the assigned value (3)
- var sel = str1 + i.toString();
- console.log('SelName: ' + sel); // should output 3 variables from loop , info0, info1 & info2
- var lineSel = $('div[class^="+sel+"]');
- lineSel.each(function(index) {
- if (index == 0) { /* target first info line */
- $(this).css({'border-top-color': 'transparent'})}
- else if (index == lineSel.length-1) { /* target last info line */
- $(this).css({'border-bottom-color': 'transparent'})}
- });
- }
First problem is that it's not changing the borders
Secondly, it's showing a final set of groups set to 5, There is a max of 5 that can be set but in this example, %id=infogroups% = 3 Not sure how loop can start running a value that's not assigned.
Thanks, Bill