I am creating html element ids by escaping text phrases, as follows:
var elementid=escape('some term entered by user');
As a result, I have a span with an id as follows:
<span class="radio" id="selectTimescalesOne%20hello%20there" style="background-position: 0px 0px; "></span>
If I attempt this:
$('#selectTimescalesOne%20hello%20there').html('some new stuff');
Then the span does not get updated. Is there something wrong with using escaped strings as ids?
%is not valid in an id. You are limited to alphanumeric characters,_,-‘:’ and., although it is wise not to use the latter three, because they cannot be used in CSS selectors.I really wouldn’t know why you want a user to input your id. Seems like bad design. If you do want to do this, just remove any invalid character or replace it with an underscore.