0
我试图取代一个连字符中的所有属性替换函数原型属性迭代
<a href="/page" id="someId" data-country="north-america" data-state="north-dakota">North Dakota</a>
像这样:
var el = document.getElementById('someId');
Array.prototype.slice.call(el.attributes).forEach(function(item) {
item.value.replace('-','_');
console.log(item.value);
});
不能完全弄清楚为什么它实际上没有与替换连字符下划线。我错过了什么吗?