![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
JavaScript
js
_Peko_
这个作者很懒,什么都没留下…
展开
-
【css】 让文字换行的样式
<span style="white-space: pre-line" > hahahahahahahahahahahahahahahahahahahh</span>原创 2021-11-29 16:07:10 · 478 阅读 · 0 评论 -
【js】 计算字符串的长度
汉字就两个长度,字符就一个长度 getByteLen(val) { let len = 0; for (let i = 0; i < val.length; i++) { let a = val.charAt(i); if (a.match(/[^\x00-\xff]/ig) != null) { len += 2; }else { len += 1;原创 2021-10-28 11:33:59 · 516 阅读 · 0 评论 -
【记录】 H5 和 JS 踩过的坑
1、通过Jquery改变标签(这里的某个标签id为add_text)的内容,可以使用$("#add_text").attr("value","字符串");但这个方法适用于 <input> ,其他标签则可用下面这个$("#add_text").text("字符串");原创 2020-09-23 20:24:29 · 135 阅读 · 0 评论 -
【JS正则表达式验证】
JS代码<script type="text/javascript">function SubmitCk() {var reg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;if (!reg.test($("#txtEmail").val())) {alert("请输入正确邮箱地址")return false;}}</sc转载 2021-01-18 20:10:09 · 74 阅读 · 0 评论 -
【js】 去除字符串首尾空格
clearSpace(str){ if(str === null){ return str; } return str.replace(/(^\s*)|(\s*$)/g, ""); }原创 2021-04-30 11:07:52 · 252 阅读 · 0 评论