Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.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_Html_Css_Selector - Fatal编程技术网

用javascript替换所有选定元素

用javascript替换所有选定元素,javascript,html,css,selector,Javascript,Html,Css,Selector,我正在尝试使用class.normal选择所有跨距。在我的网站上,剪切第一个字符并添加欧元作为最后一个字符。我真的很努力,但即使我尝试用“abc”或任何字符串替换它,它也不起作用 我的javascript如下所示: $(document).ready(function(){ var prices = document.querySelectorAll('span.normal'); for (i=0; i<prices.length; i++) { prices[i].textCo

我正在尝试使用class.normal选择所有跨距。在我的网站上,剪切第一个字符并添加欧元作为最后一个字符。我真的很努力,但即使我尝试用“abc”或任何字符串替换它,它也不起作用

我的javascript如下所示:

$(document).ready(function(){

var prices = document.querySelectorAll('span.normal');

for (i=0; i<prices.length; i++) {
  prices[i].textContent = prices[i].substring(1) + "€"; 
}

}

});
$(文档).ready(函数(){
var prices=document.queryselectoral('span.normal');

对于(i=0;i,既然您已经在使用jQuery了,那么在jQuery中完全使用它怎么样

$(文档).ready(函数(){
$('span.normal')。每个(函数(){
$(this).text($(this.text().substring(1)+'€');
});
})

abc
abc
abc
abc
var prices=document.querySelectorAll('span.normal');
对于(变量i=0;i
。正常{
字体颜色:黑色;
}
3543

34534
prices[i].textContent=prices[i].textContent.substring(1)+“€”;
@rajaprabhuaravaindasamy谢谢,但就像我说的,如果我做prices[i],事件就发生了。textContent=“abc”;它不起作用。你能分享可执行的演示/代码片段吗?如果目标浏览器是
你有一个额外的
,你可以使用
内部HTML
在您的code@Adersh是的,我贴错了。无论如何都不管用。完美地解决了它。非常感谢!