从jQuery ID 选择器文档:
If the id contains characters like periods or colons you have to escape those characters with backslashes.
Because the backslash itself need to be escaped in the string, you'll need to do this:
$("#test\\:two")
$('#test').css('background','red');
$(document.getElementById('test:two')).css('background','blue');
$('#test\\:two').css('background','green');
<script src="//code.jquery.com/jquery-1.6.3.js"></script>
<div id="test">test</div>
<div id="test:two">test two</div>
You now also have the option of using the built-in CSS.escape(...)
function, which takes care of any characters that could have special meaning inside of a selector expression.
$("#" + CSS.escape("test:two"))
$('#test').css('background','red');
$(document.getElementById('test:two')).css('background','blue');
$("#" + CSS.escape("test:two")).css('background','green');
<script src="//code.jquery.com/jquery-1.6.3.js"></script>
<div id="test">test</div>
<div id="test:two">test two</div>