2013-04-24 88 views
0

我已经得到的,看起来像这样删除Word从子

  • 项目的链接列表1
  • 项目2(富)
  • 项目3

如何获得jQuery从链接文本中删除字符串“(foo)”?

+0

是在DOM或JavaScript数组 – 2013-04-24 04:46:59

回答

3
$('a:contains(foo)').text(function(_, currentText){ 
    return currentText.replace('foo', ''); 
}); 

http://jsfiddle.net/EgHkr/

+0

是什么'_'吗? – 2013-04-24 04:48:12

+0

@Derek朕会功夫'_'是索引。 – undefined 2013-04-24 04:48:38

+0

我以为'_'是一个不能使用的特殊关键字... – 2013-04-24 04:56:01

0

另一种选择

$('li:nth-child(2)').replaceWith('<li>Item 2</li>');