Javascript, Typescript: Matching classes querySelector

This code snippet explains how to use querySelectorAll to match HTML classes using different selectors.

--- views

Matching classes querySelector

class exactly matches abc

const exactAbc = document.querySelectorAll("[class='abc']")
ts

class begins with abc

const containsAbc = document.querySelectorAll("[class*='abc']")
ts

class contains white-space separated word exactly matching abc

const containsAbc = document.querySelectorAll("[class~='abc']")
ts

class ends with abc

const endsWithAbc = document.querySelectorAll("[class$='abc']")
ts