我被轉義文本短語創建HTML元素的ID,如下所示:使用轉義字符串,如jQuery的HTML元素ID
var elementid=escape('some term entered by user');
其結果是,我有一個跨度的ID如下:
<span class="radio" id="selectTimescalesOne%20hello%20there" style="background-position: 0px 0px; "></span>
如果我嘗試這樣的:
$('#selectTimescalesOne%20hello%20there').html('some new stuff');
然後跨度沒有更新。使用轉義字符串作爲id
s有什麼問題嗎?
可能重複[什麼是HTML中的id屬性的有效值?](http://stackoverflow.com/questions/70579/what-are-valid-values-for-the-id-attribute-in- html) –
不幸的是,它看起來像你需要用其他東西來替換空格,例如下劃線'_'。 –