jQuery loop and hide on child elements of multiple parents


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. var counter;
  2. $("#ukn-clusters ul.ukn-component-main li ul").each(function() {
  3. counter = 1;
  4. $(this).children("li").each(function() {
  5. if (counter > 3) $(this).addClass('ukn-cluster-hidden').hide()
  6. counter++;
  7. });
  8. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.