0

I am generating an HTML from the json response and this can be any data.

Id can be anything like

Blue & White Dress
Black Dress

I tried like

$("['id="+dressId+"']").prop('checked', false);

But still jquery is throwing an error saying that

Error: Syntax error, unrecognized expression: ['id=Blue & White Dress']

Can you help on this?

Thanks ,Inadvance.

sree
  • 868
  • 2
  • 12
  • 35

3 Answers3

1

I think you might have your quote marks all over the place, try this. $('[id="'+dressId+'"]')

MCMXCII
  • 1,043
  • 4
  • 13
  • 26
0

HTML5 does not suppor id's with any space and also some special characters are not valid. You'll need to change you id for instance 'Blue_White_Dress' that it's valid.

Also check here, and here.

Community
  • 1
  • 1
Wilfredo P
  • 4,070
  • 28
  • 46
-1

If you are using the id you can

$("#"+showdiv+"").show();

where showdiv is the dynamic id that you have

LearningPhase
  • 1,277
  • 1
  • 11
  • 20