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
  • 758
  • 2
  • 8
  • 24

3 Answers3

1

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

MCMXCII
  • 1,041
  • 3
  • 14
  • 25
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
  • 3,959
  • 25
  • 44
-1

If you are using the id you can

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

where showdiv is the dynamic id that you have

LearningPhase
  • 1,175
  • 1
  • 10
  • 19