Why I receive this error?
Uncaught Error: Syntax error, unrecognized expression: #15/12/2015(…)
When I execute this?
jQuery('#15/12/2015').addClass('full').removeClass('empty');
Each row contain date as id in this format id="dd/mm/yyyy"
How can i resolve it by putting id in this row?
jQuery('#' + id).addClass('full').removeClass('empty');
Thanks very much for any replies!!
M.
Solution 1:
Use attribute equals selector:
jQuery('[id="15/12/2015"]').addClass('full').removeClass('empty');
you can concatenate id using:
jQuery('[id="' + id + '"]').addClass('full').removeClass('empty');
Solution 2:
convert / in id value to \\/ to create valid id selector:
id = "15/12/2015"
$('#'+id.replace(/\//g, "\\/")).addClass('full').removeClass('empty');
Working Demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With