Selector question

Selector question

I don't understand why I'm getting:
uncaught exception: Syntax error, unrecognized expression: Syntax error, unrecognized expression: j_id1\\
  1. // {!$Component.bla.bal} comes from the platform I'm working with, not a jquery thing.
  2. var elmId = "#{!$Component.theComponent.theForm.theValue}";
  3. // elmId now holds a string of: j_id0:j_id1:theComponent:theForm:theValue
  4. // do a replace to escape all colons in the id.
  5. elmId = elmId.replace(/:/g,"\\\\:");
  6. // elmId now holds a string of: j_id0\\:j_id1\\:theComponent\\:theForm\\:theValue
  7. // when I do this I get the exception
  8. $(elmId).val('foo');
  9. // but when I do this without escaping, everything works great
  10. $('input[id='+elmId+']').val('foo');
So I have a workaround but I'm trying to understand why $(elmId) throws an exception. Any thoughts?