Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function(){
- $( document ).ready(function() {
- // Find every element with class .pick-kolumn
- $('.pick-kolumn').click(function() {
- // Find index number from attribute data-column found on the button
- var columnIndex = $(this).attr('data-column');
- // For loop for each element that has a class of .kolumna
- $('.column').each(function(index, element) {
- var $element = $(element);
- // Remove all column-chosen classes from .kolumna
- $element.removeClass('column-chosen');
- // Each element in the loop has an index attribute, we check here if
- // the index of the element matches the one from the data-attribute if yes
- // we add .column-chosen
- // index is a number and columnIndex is a string so we need to convert
- // the number to a string to check for equality
- if (index.toString() === columnIndex) {
- $element.addClass('column-chosen');
- }
- })
- })
- })
- })()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement