2
我使用jQuery的下面包裹在我的元素每個字母在跨度:jQuery - 在<span>中包裹一個逗號?
$('.num .stat').children().andSelf().contents().each(function() {
if(this.nodeType == 3) {
var $this = $(this);
$this.replaceWith($this.text().replace(/(\w)/g, '<span class="s-$&">$&</span>'));
}
});
我會用這個來包裹號。我遇到的問題是,當我的號碼中有一個逗號(例如23,000)時,逗號沒有被包裹。
任何想法如何我可以得到逗號包裹在<span>
也?
謝謝!
+1 ....像那.... – thecodeparadox