0

i've a div with an id that encoded with base64 encryption. it looks like this:

<div id="tagValue_16DXp9eR15Q=">

and when im trying to delete it by using the id like that:

$('div[id=tagValue_tagValue_16DXp9eR15Q=]').remove();

im getting the following error:

Uncaught Error: Syntax error, unrecognized expression: div[id=tagValue_16DXp9eR15Q=] 

but when i remove the " = " from the encryption it works:

<div id="tagValue_16DXp9eR15Q">

it will work with the code:

$('div[id=tagValue_tagValue_16DXp9eR15Q]').remove();

how can i make it work and also leave the " = " ?

0

2 Answers 2

4

You can select ids as such:

$('#tagValue_tagValue_16DXp9eR15Q\\=').remove();

instead of trying to grab it as an attribute. Your earlier problem was due to the equals sign being syntactically significant. You can avoid this by quoting in the attribute selector:

$('div[id="tagValue_tagValue_16DXp9eR15Q="]').remove();
Sign up to request clarification or add additional context in comments.

2 Comments

works like a charm. thanks! i can't believe i didnt think about that
The = will need to be escaped in the ID selector -- $('#tagValue_tagValue_16DXp9eR15Q\\=').
2

Maybe:

$('div[id="tagValue_tagValue_16DXp9eR15Q="]').remove();

? Just don't forget that string is a string ;o)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.