Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How do I select an element by an ID that has characters used in CSS notation?

0
0 Posted

How do I select an element by an ID that has characters used in CSS notation?

0
0

Because jQuery uses CSS syntax for selecting elements, some characters are interpreted as CSS notation. For example, ID attributes, after an initial letter (a-z or A-Z), may also use periods and colons, in addition to letters, numbers, hyphens, and underscores (see W3C Basic HTML Data Types). The colon (“:”) and period (“.”) are problematic within the context of a jQuery selector because they indicate a pseudo-class and class, respectively. In order to tell jQuery to treat these characters literally rather than as CSS notation, they must be “escaped” by placing two backslashes in front of them.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123