Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(".display-player-box").each(function() { // start looping
- $selected = 0; // set a variable to default
- $boxid = $(this).attr("id"); // set id of element being looped as variable
- $(".removefromsquad").each(function() { // loop through another row of elements
- if ($(this).attr("class").slice(16, 17) == $boxid) { // looking for part of it's class matching previously saved variable
- $selected = 1; // if yes, update variable
- };
- });
- if ($selected == 1) { // if variable was updated...
- $(this).addClass("selected"); // add class to .display-player-box
- } else { // if not...
- $(this).removeClass("selected"); // make sure it's removed
- }
- });
- $(".display-player-box").each(function() {
- var selected = false;
- var selfId = $(this).attr('id');
- $('.removefromsquad').each(function() {
- if ($(this).hasClass(selfId)) {
- selected = true;
- }
- });
- if (selected) {
- $(this).addClass('selected');
- } else {
- $(this).removeClass('selected');
- }
- });
Add Comment
Please, Sign In to add comment