Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6209657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:01:30+00:00 2026-05-24T06:01:30+00:00

for meta data on the page using attribute names like table:rowNum:<name> , eg, var

  • 0

for meta data on the page using attribute names like table:rowNum:<name>, eg,

var row = document.createElement('tr');
row.setAttribute('tup','emp:1');
row.setAttribute('emp:1:pkid','123');

have been using colon-delimited names (eg, name='emp:1:emp_id') for years with good success, but today got bit with colon delimited attribute names

in particular:

var el2 = row.parentNode.querySelector("[emp:1:pkid]");
=> `Error: SYNTAX_ERR: DOM Exception 12`

are special character like ‘:’ illegal in dom attribute names? can special characters be escaped to work with querySelector()?


from chrome console:

> row.parentNode.querySelector('[emp:1:pkid]');
Error: SYNTAX_ERR: DOM Exception 12

as per James (below):

> row.parentNode.querySelector('[emp\\:1\\:pkid]');
123

but Problem – does not work with getAttribute – pia

> row.getAttribute('emp:1:pkid');
123
> row.getAttribute('emp\\:1\\:pkid');
null
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:01:31+00:00Added an answer on May 24, 2026 at 6:01 am

    It seems that you can escape the special characters with a double backslash:

    var el2 = element.querySelector("[emp\\:1\\:update]");
    

    I think the problem is to do with the fact that a colon would normally indicate a pseudo element.

    According to the WHATWG spec, any characters except those that would change the context (e.g. an equals character, as that specifies the start of the value, or a greater-than character, which would specify the end of the tag). On that basis, it’s fine to use colon characters in attribute names.

    Update (based on comments on answer and updates on question)

    To use one variable with both querySelector and getAttribute, you could do something like this, or you could just store the version with escaped characters, and one without (which would definitely be my preferred option):

    var s = "emp\\:1\\:update";
    console.log(row.getAttribute(s.replace(/\\/g, "")));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an object I am using to store document meta data into a
I would like to display certain meta data fields in the edit form based
I have a table of data, and I allow people to add meta data
I am trying to access information from an Oracle meta-data table from within a
This is the code i am using: <!DOCTYPE html> <html lang=en> <head> <meta name=viewport
I am using the following html page: <html> <head> <title>AJAX Example</title> <meta http-equiv=Content-Type content=text/html;
I would like to append some code to a page using jQuery/jQuery mobile, but
I'm using the Facebook like plugin. So, when you are on a page and
Is it possible to make modifications in the meta data of an HTML page
Using the jquery metadata plugin, I have an element on my page that looks

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.