64
2021-06-15 14:09:25 64阅读 0喜欢
<div id="text">good1230.com-专注于网站排名优化博客建站系统和好文分享</div>

let context = document.getElementById("text")
context.addEventListener('mouseup',() => {
    const selection = window.getSelection()
    const text = selection.toString()
})
2020-09-23 17:23:14 118阅读 0喜欢
896访问人次
Camila Waz 2021-06-15 17:14:53
219
2019-12-04 17:01:06 219阅读 0喜欢

字符串转数组split() 函数和数组转字符串join() 函数实例

var string="abcdefg"
console.log(string.split(''));
// 输出结果:["a", "b", "c", "d", "e", "f", "g"]

var array=["a", "b", "c", "d", "e", "f", "g"];
console.log(array.join(','));
// 输出结果:a,b,c,d,e,f,g
79
2019-11-28 18:01:19 79阅读 0喜欢

JavaScript toFixed() 方法可把Number值四舍五入为指定小数位数的数字。

function format(point) {
  var num = new Number(point);
  return num.toFixed(3)
}
console.log(format('2.236834234'))
// 输出结果 2.237
119
2019-11-20 11:00:25 119阅读 0喜欢
  • <input type="text" oninput="value= value.match(/\d+(\.\d{0,2})?/) ? 
    this.value.match(/\d+(\.\d{0,2})?/)[0] : ''" placeholder="请输入...">
    
2019-10-29 15:47:03 74阅读 0喜欢
2019-10-29 15:16:28 68阅读 0喜欢
2019-10-08 16:22:02 79阅读 0喜欢