如何在<span>之后获取文本

时间:2015-07-24 07:02:23

标签: javascript jquery

 var items = $(".landingpage .tableCol-33:nth-child(3) tbody:nth-child(even) tr td");
      $.each(items, function(i, val){
      var item = $(val);
         var next_text = item.text().substring(14, 30);
          var sub_text = item.find('a').html();
          var new_text=sub_text.substring(item.find('a').html().lastIndexOf("</span>"),sub_text.length);
        item.find("a").text(next_text);

   })
});

我有上面的代码来实现这个目的:

结构如下:<Expand collapse icon>SUbcategory:Mutual FUnds

HTML

<td colspan="100" nowrap="nowrap" class="ms-gb">
    <a href="javascript:" onclick="javascript:ExpCollGroup('13-1_', 'img_13-1_',event, false);return false;">
    <span class="ms-commentcollapse-iconouter">
    <img class="ms-commentcollapse-icon" src="/_layouts/15/images/spcommon.png?rev=23" alt="expand" id="img_13-1_"></span>
    Subcategory</a> : Mutual Funds <span style="font-weight: lighter; display: inline-block;">(4)</span>
</td>

我必须用共同基金替换子类别,保留图标。

0 个答案:

没有答案