You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I was wondering if it would be worth adding something in the chapter Searching: getElement, querySelector about how to pass a variable through document.querySelector by using CSS.escape(), ie document.querySelector('div.' + CSS.escape(userColor))
I write this because I just spent a while trying template literals, etc, and I had no idea CSS.escape() existed and is necessary to do this.
It's probably pretty uncommon to need to pass variables to querySelector, but if anyone else thinks it's worth adding I would be happy to make a PR.
Hello, I was wondering if it would be worth adding something in the chapter Searching: getElement, querySelector about how to pass a variable through
document.querySelector
by usingCSS.escape()
, iedocument.querySelector('div.' + CSS.escape(userColor))
I write this because I just spent a while trying template literals, etc, and I had no idea CSS.escape() existed and is necessary to do this.
It's probably pretty uncommon to need to pass variables to querySelector, but if anyone else thinks it's worth adding I would be happy to make a PR.
https://developer.mozilla.org/en-US/docs/Web/API/CSS/escape
The text was updated successfully, but these errors were encountered: