0

the HTML DOM classList Property:

   document.getElementById("x").classList.add("y");

and HTML DOM getElementsByClassName() Method

document.getElementsByClassName("x");

are not supported by older versions of browsers. how to check if a browser supports them? and is there any fallback functions that can replace them in case they are not supported

Tim
  • 79
  • 5
  • Try not to ask three questions at the same time in future. – Quentin Aug 10 '17 at 15:09
  • document.getElementById() is supported from IE 5.5 so I guess the problem is only document.getElementsByClassName() which is not supported prior IE9. Use your favorite search engine and give it a go with "document.getElementsByClassName polyfill" – caramba Aug 10 '17 at 15:12

1 Answers1

0

getElementByClassName has a very good support.

classList also, but you can fallback with className which is a String not a DOMTokenList.

consider using document.querySelector and document.querySelectorAll instead.

Hitmands
  • 13,491
  • 4
  • 34
  • 69