我需要<li>
用句号替换每个值中的逗号。
我不知道我的代码有什么问题。我检查了控制台,但是什么都没有...
$('#stats li').each(function () {
$(this).text().replace(/,/g, '.');
});
此代码应针对每个<li>
在<ul id="stats">
。然后,应替换每个,
中的每个<li>
,然后将其替换为.
我也尝试过这个:
$('#stats li').each(function () {
var comma = /,/g;
if(comma.test($this)) {
$(this).replace(comma, '.');
}
});
我尝试了这个:
$('#stats li').each(function () {
var stats = [];
stats.push($(this).text());
stats.replace(/,/g, '.');
console.log(stats);
});
这是小提琴。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句