Jquery colon conflict
HTML allows to use as a valid identifier (ID) a colon. For example:
<div id="item:0">...</div>
The problem is I have a Jquery snippet like this:
$("#" + id).clone(true, true);
When some ID uses a colon this call makes JQuery crash. What can I d开发者_如何学JAVAo to make it work? (Note: changing colon symbol for other valid character is not an option)
Escape the id with something like
id = id.replace(':', '\\:');
before you try selecting it.
You say changing the id is not possible - but could you change the id with javascript client side?
Otherwise, you could assign a class to each element that has id with colon, and select them by their class.
Can't you clone a div, not by id?
精彩评论