Guest User

Untitled

a guest
May 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. $(".display-player-box").each(function() { // start looping
  2. $selected = 0; // set a variable to default
  3. $boxid = $(this).attr("id"); // set id of element being looped as variable
  4. $(".removefromsquad").each(function() { // loop through another row of elements
  5. if ($(this).attr("class").slice(16, 17) == $boxid) { // looking for part of it's class matching previously saved variable
  6. $selected = 1; // if yes, update variable
  7. };
  8. });
  9. if ($selected == 1) { // if variable was updated...
  10. $(this).addClass("selected"); // add class to .display-player-box
  11. } else { // if not...
  12. $(this).removeClass("selected"); // make sure it's removed
  13. }
  14. });
  15.  
  16. $(".display-player-box").each(function() {
  17. var selected = false;
  18. var selfId = $(this).attr('id');
  19. $('.removefromsquad').each(function() {
  20. if ($(this).hasClass(selfId)) {
  21. selected = true;
  22. }
  23. });
  24.  
  25. if (selected) {
  26. $(this).addClass('selected');
  27. } else {
  28. $(this).removeClass('selected');
  29. }
  30. });
Add Comment
Please, Sign In to add comment