Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. (function(){
  2. $( document ).ready(function() {
  3. // Find every element with class .pick-kolumn
  4. $('.pick-kolumn').click(function() {
  5. // Find index number from attribute data-column found on the button
  6. var columnIndex = $(this).attr('data-column');
  7. // For loop for each element that has a class of .kolumna
  8. $('.column').each(function(index, element) {
  9. var $element = $(element);
  10. // Remove all column-chosen classes from .kolumna
  11. $element.removeClass('column-chosen');
  12. // Each element in the loop has an index attribute, we check here if
  13. // the index of the element matches the one from the data-attribute if yes
  14. // we add .column-chosen
  15. // index is a number and columnIndex is a string so we need to convert
  16. // the number to a string to check for equality
  17. if (index.toString() === columnIndex) {
  18. $element.addClass('column-chosen');
  19. }
  20. })
  21. })
  22. })
  23. })()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement