转类型:
转字符串类型 :toString;
转布尔值:Boolean;
转数字:Number;
字符串转对象:JSON.stringify;
转大小写:toUpperCase;toLowerCase;
2.节点
创建节点:createElement
添加节点;appendChild (insertBefore)
删除节点:removeChild
3.获取元素的方式
document.getElementById();
document.getElementByClassName()[0];
document.getElementByName()[0];
document.getElementByTagName()[0];
document.querySelector();
document.querySelectorAll()[0];
返回元素子节点:children
返回元素父节点:parentNode
3.截取字符串方法
substring()
slice();
substr();
4.定时器
设置定时器:setTimeout();setInterval();
清除定时器:clearInterval();clearTimeout();
5.随机数
math.random
向下取整:Math.floor();
向上取整:Math.ceil();
绝对值:Math.abc();
本文详细介绍了JavaScript中常用的类型转换方法,如toString、Boolean、Number等,并探讨了DOM操作,包括创建、添加、删除节点及获取元素的各种方式。此外,还讲解了字符串截取、定时器的使用以及随机数生成的相关函数。内容深入浅出,适合JavaScript初学者及进阶者阅读。
514

被折叠的 条评论
为什么被折叠?



