              for (var i = 0; i < ps.length; i++) {
                  if (ps[i].className.indexOf("info") !== -1) {
                      // Remove <p class="info">, because it just gets in the way.
                      from_box.parentNode.removeChild(ps[i]);
                  } else if (ps[i].className.indexOf("help") !== -1) {
                      // Move help text up to the top so it isn't below the select
                      // boxes or wrapped off on the side to the right of the add
                      // button:
                      from_box.parentNode.insertBefore(ps[i], from_box.parentNode.firstChild);
                  }
 
</s> remove                 if (ps[i].className.indexOf("info") !== -1) {
 </s> add                 if (ps[i].classList.contains("info")) { </s> remove                 if (elem.className.indexOf('active') !== -1) {
 </s> add                 if (elem.classList.contains('active')) { </s> remove                 if (inp.type === 'text' && inp.className.match(/vTimeField/)) {
 </s> add                 if (inp.type === 'text' && inp.classList.contains('vTimeField')) { </s> remove                 if (elem.className.indexOf('vManyToManyRawIdAdminField') !== -1 && elem.value) {
 </s> add                 if (elem.classList.contains('vManyToManyRawIdAdminField') && elem.value) { </s> remove         if (elem.className.indexOf('vManyToManyRawIdAdminField') !== -1 && elem.value) {
 </s> add         if (elem.classList.contains('vManyToManyRawIdAdminField') && elem.value) {
                } else if (ps[i].classList.contains("help")) {
              for (var i = 0; i < ps.length; i++) {
                  if (ps[i].className.indexOf("info") !== -1) {
                      // Remove <p class="info">, because it just gets in the way.
                      from_box.parentNode.removeChild(ps[i]);
                } else if (ps[i].classList.contains("help")) {
                      // Move help text up to the top so it isn't below the select
                      // boxes or wrapped off on the side to the right of the add
                      // button:
                      from_box.parentNode.insertBefore(ps[i], from_box.parentNode.firstChild);
                  }
keep keep keep keep replace keep keep keep keep keep
 Fixed #31028 -- Used classList API to check, add and remove DOM classes.

Thanks to Claude Paroz for review. 
django/contrib/admin/static/admin/js/SelectFilter2.js