I have a jQuery loop that appends multiple rows to a table. The number of rows can change at run-time, so the row ID is generated dynamically.
$("#tableBody")
.append($("<tr>")
.attr('id','row-icon' + currentID)...
At a later point, I then need to access these added rows. However, when the value of currentID
has a '+' symbol in it - I get an "undefined" error when I try to access the row element.
For example, the line below works when currentID
is "1" - but it fails when the ID is "vm+1".
var testID = $("#row-icon" + currentID).attr("id");
Am I missing an easy solution to "escape" the extra '+' symbol?
Working example here.
EDIT: I should note that the id's are being sent by a 3rd-party - so I have no control over removing the '+' symbol.