Generally when using query selector in javascript we do like this,
ABCD
var className = \'abcd\';
You can escape it using two backslashes (\\
) in your js string (it'll be evaluated as \
and finally interpreted as an escape character by CSS parser).
var className = 'abcd\\/efgh';
var x = document.querySelector('.' + className);
console.log(x);
ABCD
Source