At the moment I'm writing a webchat, in which the user can open a new room with URI-GET params. The PHP part creates the html and sends it to the browser.
But if the user types in the URI something like /?Mychat%20%231 my PHP sends a chat named Mychat_#1.
This still works correctly but when I try to refresh the chat (every second) I always get
SyntaxError: 'section.Mychat_#1' is not a valid selector
Every chat looks like this:
<section class="chat-container chat_name_#1"><!-- <- I try to get this node via the chat name -->
    <header>
        chat_name_#1
    </header>
    <div class="msg-container" style="">
        <section><!-- here the messages will be inserted --></section>
    </div>
    <footer>
        <div class="msg">
            <input name="msg" autocomplete="off" type="text">
        </div>
        <div class="btn">
            <button>senden</button>
        </div>
    </footer>
</section>
in my main.js file I tried to get the node with document.querySelector
for(DATA in CHAT){
    let chat = document.querySelector('section.' + CHAT[DATA].title);
    // ...
}
Normal the hashtag character is allowed in class names (if they don't start with it)
My Question is not a duplicate of Which characters are valid in CSS class names/selectors.
Before I asked it, I searched on Google and find it too. I read it but there was only explained, what CSS selectors are allowed. In my case it unfortunately didn't help.
 
     
     
    