Skip to main content
2 of 2
Escape a string for use as part of a selector

Without JQuery, ES6

document.querySelectorAll(`[data-slide='${CSS.escape(current)}']`); 

I know the question is about JQuery, but readers may want a pure JS method.

rap-2-h
  • 32.3k
  • 49
  • 190
  • 281