避免使用jQuery的html方法来替换标签,而是使用replaceWith方法

tblCostSplit.html内容:

<nobr title="">只想显示里面内容,去掉nobr标签</nobr>

<nobr title="">只想显示里面内容,去掉nobr标签</nobr>

<nobr title="">只想显示里面内容,去掉nobr标签</nobr>

(1)html方法,会导致原来Dom内容的绑定事件出现错误,不建议使用

tblCostSplit.html(tblCostSplit.html().replace(/<nobr.*?>/ig, "").replace(/<\/nobr>/ig, ""));

(2)replaceWith方法,能正常替代标签,建议使用

jQuery("nobr", tblCostSplit).each(function () {

jQuery(this).replaceWith(jQuery(this).html());

});