常用的js函数大全(自用)有搬运的

类型转换:

parseInt(整数)\parseFloat(浮点)\toString (转化字符)。。还有 转化数字一些其中具体的细节不写了! 

类型判断:

1.typeof; 

     

console.log(bool instanceof Boolean);// false
console.log(num instanceof Number);// false
console.log(str instanceof String);// false
console.log(und instanceof Object);// false
console.log(nul instanceof Object);// false
console.log(arr instanceof Array);// true
console.log(obj instanceof Object);// true
console.log(fun instanceof Function);// true
console.log(s1 instanceof Symbol);// false

 

字符处理函数:

toLowerCase\touppercase\(大小写) 
substring(从哪里截到哪)

substr(从哪里开始;截多少个字符)

indexOf(字串中找某串字符)

replace(替换函数)
charCodeAt   返回Unicode编码
concat  拼接
split       通过什么符号或者数字进行对数组的分割
join        用什么把数组中的数据进行拼接起来

定时处理函数:

setInterval;setTimeout;clearTimeout;clearInterval

两个显示控制属性:

visibility(hidden,hide,show,visible);

display(none,block,inline)

编码的一些函数:escape();

取得对象的方法:
document.getElementsByTagName(根据标签名获得对象组)\
document.getElementsByTagName('head').item(0)
document.getElementsByName(通过NAME获得对象)\
document.getElementById(通过ID获得对象)\
document.form1.f1\
document.all.tags(t)[id]
document.all[id]
document.layers[id]

不常用的一些方法:
moveToAbsolute:
fromElement
toElement
contains
captureEvents
parent.frames
moveTo(x,y)
resizeBy(x,y)
resizeTo(x,y)
attachEvent('onmousedown',showHide);
document.createElement('')
document.createTextNode('')
obj.setAttribute('src','')
obj.getAttribute('')
event.srcElement
style.cssText
document.body.appendChild
document.body.removeChild
document.body.insertAdjacentHTML("AfterBegin",s)
innerHTML/
removeNode
insertBefore
arguments
event.keyCode

正则相关:RegExp(eg:new RegExp("\"","g"))

一些长宽及位置属性:
window.innerHeight
window.innerWidth
document.documentElement.clientWidth
document.documentElement.clientHeight
document.body.clientWidth
document.body.clientHeight
document.body.offsetWidth
document.body.offsetHeight
document.body.scrollLeft
document.body.scrollTop
document.location.reload()

window一些方法:
window.οnerrοr=function(){return true;}隐去报错
window.onload\window.onunload
window.status
window.parent.location.href
window.location.href
window.top.location.href

数学方法:
Math.max

数组方法:
length
slice

JS输出方法:
document.write(s);
alert(s);
confirm
prompt
document.writeln
弹窗方法:
window.showModalDialog(<url>,<标题>,<属性>)
window.open("","","");


附:常用DOM方法和属性(即必须掌握部分)

创建节点:createElement();createTextNode()
复制节点:cloneNode()
插入节点:appendChild();insertBefore()
删除节点:removeChild()
替换节点:replaceChild()
设置节点属性:setAttribute()
查找节点:getAttribute();getElementById();getElementsByTagName();hasChildNodes
节点的属性:nodeName;nodeType;nodeValue
遍历节点树:childNodes;firstChild;lastChild;nextSibling;parentNode;previousSibling

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值