2013-04-24 85 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>');