WEB前端工程师整理的原生JavaScript经典百例

WEB前端工程师整理的原生JavaScript经典百例

推荐下我的web前端学习群:688676066,每天晚上20:00我都会开直播给大家分享web前端学习知识和路线方法,群里会不定期更新最新的教程和学习方法(进群送web前端学习教程)关注weixin,v微创文化,大家都是学习web前端的,或是转行,或是大学生,还有工作中想提升自己能力的web党,如果你是正在学习web前端的小伙伴可以加入学习。最后祝所有程序员都能够走上人生巅峰,让代码将梦想照进现实。

一、原生JavaScript实现字符串长度截取

WEB前端工程师整理的原生JavaScript经典百例

二、原生JavaScript获取域名主机

WEB前端工程师整理的原生JavaScript经典百例

三、原生JavaScript转义html标签

WEB前端工程师整理的原生JavaScript经典百例

四、原生JavaScript时间日期格式替换

Date.prototype.Format = function(formatStr) {

var str = formatStr;

var Week = ['日', '一', '二', '三', '四', '五', '六'];

str = str.replace(/yyyy|YYYY/, this.getFullYear());

str = str.replace(/yy|YY/, (this.getYear() % 100) > 9 ? (this.getYear() % 100).toString() : '0' + (this.getYear() % 100)); str = str.replace(/MM/, (this.getMonth() + 1) > 9 ? (this.getMonth() + 1).toString() : '0' + (this.getMonth() + 1));

str = str.replace(/M/g, (this.getMonth() + 1));

str = str.replace(/w|W/g, Week[this.getDay()]);

str = str.replace(/dd|DD/, this.getDate() > 9 ? this.getDate().toString() : '0' + this.getDate());

str = str.replace(/d|D/g, this.getDate());

str = str.replace(/hh|HH/, this.getHours() > 9 ? this.getHours().toString() : '0' + this.getHours());

str = str.replace(/h|H/g, this.getHours());

str = str.replace(/mm/, this.getMinutes() > 9 ? this.getMinutes().toString() : '0' + this.getMinutes());

str = str.replace(/m/g, this.getMinutes());

str = str.replace(/ss|SS/, this.getSeconds() > 9 ? this.getSeconds().toString() : '0' + this.getSeconds());

str = str.replace(/s|S/g, this.getSeconds());

return str

五、原生JavaScript判断是否为数字类型

WEB前端工程师整理的原生JavaScript经典百例

六、原生JavaScript获取cookie值

WEB前端工程师整理的原生JavaScript经典百例

七、原生JavaScript格式化CSS样式代码

WEB前端工程师整理的原生JavaScript经典百例

八、原生JavaScript实现checkbox全选与全不选

WEB前端工程师整理的原生JavaScript经典百例

九、原生JavaScript根据样式名称检索元素对象

WEB前端工程师整理的原生JavaScript经典百例

十、原生JavaScript判断是否以某个字符串开头

WEB前端工程师整理的原生JavaScript经典百例

十一、原生JavaScript获取页面scrollLeft

WEB前端工程师整理的原生JavaScript经典百例

十二、原生JavaScript跨浏览器添加事件

WEB前端工程师整理的原生JavaScript经典百例

十三、原生JavaScript用正则表达式清除相同的数组(高效率)

WEB前端工程师整理的原生JavaScript经典百例

如果有对前端感兴趣前端程序员,可来我们的web前端技术学习群的哦688676066,里面免费送前端的零基础教程噢!


写在最后:


很多人都知道我是学全栈的,都天真的以为我有全套的前端、网页制作等视频学习资料。我想说你们是对的,我的确有前端的全套视频资料。


猜你喜欢

转载自blog.csdn.net/qq_40433465/article/details/80076889