Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/468.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我如何用javascript替换一个类下多个位置的单词?_Javascript_Replace_Google Chrome Extension - Fatal编程技术网

我如何用javascript替换一个类下多个位置的单词?

我如何用javascript替换一个类下多个位置的单词?,javascript,replace,google-chrome-extension,Javascript,Replace,Google Chrome Extension,我正在编写一个chrome扩展来为一个项目重新设计tumblr仪表板 这是一件小事,但一直很令人沮丧。我想在每篇文章下面的注释数量之后去掉“注释”这个词 字符串在一个类下。注意\u link\u current,所以我尝试了这个 var textNotes = $('.note_link_current').text(); textNotes = textNotes.replace('notes', ' '); $('.note_link_current').text(textNotes);

我正在编写一个chrome扩展来为一个项目重新设计tumblr仪表板

这是一件小事,但一直很令人沮丧。我想在每篇文章下面的注释数量之后去掉“注释”这个词

字符串在一个类下。注意\u link\u current,所以我尝试了这个

var textNotes = $('.note_link_current').text();
textNotes = textNotes.replace('notes', ' ');
$('.note_link_current').text(textNotes);
似乎发生的是,我得到了所有帖子的所有注释的组合字符串。。我如何获得它,使其单独影响所有人

现在我得到的是这样的东西:

251 
                63 notes441 notes74 notes851 notes49,263 notes2,561 notes142 notes1 note651 notes 

任何帮助都将不胜感激

费利克斯克林说了些什么,但有更多的解释:

类似于
$('.note\u link\u current')
的jQuery选择器将返回一个节点数组。您正在尝试对此阵列执行操作,就像它是一个节点一样

相反,您应该做的是调用
.each()
,对每个元素执行操作

$('.note_link_current').each( function(index) {
  // Inside this function, "this" refers to the (DOM) element selected
  var text = $(this).text();
  /* ... */
});
->