1

I'm trying to use jQuery selectors to select a table with an id containing some special characters, { and } but I get errors in the console and script is not executed, not sure why:

Error text

Refused to apply inline style because it violates the following Content Security Policy directive: "default-src 'none'". Either the 'unsafe-inline' keyword, a hash ('sha256-33YGiROm4Pzv0xXIPo82M0Dt2zrdnP4IgbJq1WeAtf8='), or a nonce ('nonce-...') is required to enable inline execution. Note also that 'style-src' was not explicitly set, so 'default-src' is used as a fallback.

(anonymous) @ jquery-1.4.2.min.js:33
(anonymous) @ jquery-1.4.2.min.js:37
(anonymous) @ jquery-1.4.2.min.js:154

Here's my HTML table

<table border="0" cellspacing="0" dir="none" cellpadding="1" id="{7B414D25-2C68-4ACF-A923-85EAE66F82D0}-{AFEC83B3-EBCC-4EC5-8C9D-1AEF0B30902F}" class="ms-listviewtable" view="AFEC83B3-EBCC-4EC5-8C9D-1AEF0B30902F">

And my jQuery

jQuery('#{7B414D25-2C68-4ACF-A923-85EAE66F82D0}-{AFEC83B3-EBCC-4EC5-8C9D-1AEF0B30902F}').append('<div>I am here!!!</div>');  

Any suggestions on what I'm doing wrong?

dadde
  • 649
  • 1
  • 11
  • 24
  • 2
    [_To use any of the meta-characters ( such as __!"#$%&'()*+,./:;<=>?@[\]^`{|}~__ ) as a literal part of a name, it must be escaped with with two backslashes: \\. For example, an element with id="foo.bar", can use the selector $("#foo\\.bar"). The W3C CSS specification contains the complete set of rules regarding valid CSS selectors. Also useful is the blog entry by Mathias Bynens on CSS character escape sequences for identifiers._](https://api.jquery.com/category/selectors/) – Pranav C Balan Feb 02 '17 at 13:32
  • @PranavCBalan Perfect man, quick and correct answer! – dadde Feb 02 '17 at 13:33
  • 1
    Better Duplicate: http://stackoverflow.com/questions/2786538/need-to-escape-a-special-character-in-a-jquery-selector-string – Rajesh Feb 02 '17 at 13:34

0 Answers0