jQuery删除具有非标准id字符的表行

问题描述:

我正在尝试使用jQuery删除表格行

I am trying to remove a table row using jQuery like this

function removeTableRow(trId){
    $('#' + trId).remove();
}

但是如果id包含像%这样的字符,这不起作用,^,&,,等....

However this doesn't work if the id contains a character like "%", "^", "&", ",", etc....

你知道是否有任何解决方法吗?

Do you know if there is any work around for this?

我相信原因可以在这里找到: HTML中id属性的有效值是什么?

I believe the reason why can be found here: What are valid values for the id attribute in HTML?

但是除了显而易见的(改变你的ID)

However I'm not so sure about a workaround other than the obvious (change your ids)