我希望删除文本" DocumentType:"来自以下HTML(我不关心标题或alt):
<tr class="ms-gb" ishdr="true" isexp="true">
<td colspan="100" nowrap="nowrap">
<a href="javascript:" onclick="ToggleSPGridViewGroup(this, false)" title="Expand/Collapse DocumentType : Agreement - Contract">
<img src="/_layouts/images/minus.gif" border="0" alt="Expand/Collapse DocumentType : Agreement - Contract"/>
</a>
 DocumentType : Agreement - Contract
</td>
</tr>
在页面中,我已经有了一些循环遍历&#34; ms-gb&#34;分类元素,但我似乎无法潜入适当的元素来找到&#34; DocumentType:&#34;为了使用空文本执行.replace():
<script type="text/javascript">
$(document).ready(function () {
$(".ms-gb").each(function () {
var rowNums = $(this).nextUntil(".ms-gb").length;
$(this).children(0).append(" (" + rowNums + ")");
$(this).html().replace("DocumentType : ",""); //This is horribly incorrect
});
});
</script>
如何正确键入此文本以替换&#34; DocumentType:&#34;带有空字符串的文字?
答案 0 :(得分:2)
您还必须设置html
:
var currentHtml = $(this).html();
currentHtml = currentHtml.replace("DocumentType : ","");
$(this).html(currentHtml);