好多人想要學習前端……自學或者培訓那麼咱們在學習過程當中到底須要掌握那些基礎知識呢!下面分類了JS中必備的知識也是必需要了解學會的!看一看你是否已經將JS的基礎知識都瞭如指掌了呢?php
事件:前端
onmousedown 鼠標按下 node
onmouseup 鼠標擡起 ajax
onmouseover 鼠標移入 json
onmouseout 鼠標移除 數組
onmousemove 鼠標移動 瀏覽器
onclick 點擊事件 app
onfocus 得到焦點 框架
onblur 失去焦點 dom
oncontextmenu 鼠標右鍵
onsubmit 表單提交//不會有冒泡的,坑
onkeydown 鍵盤按下
onkeyup 鍵盤擡起
onload 頁面加載
onscroll 頁面滾動
onresize 窗口大小變化
鼠標滾輪事件onmousewheel DOMMouseScroll
輸入框中value改變觸發的事件onreadystatechange
attachEvent事件綁定(IE)addEventListener 事件綁定(標準)
event對象
clientX/clientY 鼠標當前窗口的位置
取消冒泡cancelBubble
鍵盤鍵值keyCode 特殊的鍵值Event altKey、ctrlKey、shiftKey
阻止默認事件preventDefault()return false
DOM操做:
getElementById 獲取ID元素
getElementsByTagName 獲取class類元素
childNodes 子節點 特殊瀏覽器包括默認的文本節點(換行等……)
children 子節點
firstChild/firstElementChildlastChild/lastElementChild兄弟節點
nextSibling/nextElementSiblingpreviousSibing/previousElementSibing
parentNode 父節點
offsetParent 有定位屬性的父節點
nodeType 節點類型
offsetWidth 元素的寬度(包括padding和border)
offsetHeight 元素的高度(包括padding和border)
clientWidth 可視區寬度
clientHeight 可視區高度
createElement 建立dom節點
appendChild 插入子節點
insertBefore 在子節點的第一個前面插入
removeChild 刪除子節點
replaceChild 替換節點 並返回被替換元素
BOM操做:
window.open()
window.close()
window.location
window.location.search
window.location.hash
window.navigator.userAgent
js基礎:
判斷
if else
switch case
循環
for
for in
while
跳出循環
continue
break
比較undefined null === == !
定時器類
setTimeout
clearTimeout
setInterval
clearInterval
參數集合
arguments
調整this
call
apply
callee
數組和數組操做
var arr = [];
var arr = new Array();
push
pop
shift
unshift
splice
join
sort
concat
字符串操做
split
substring
indexOf
charAt
正則
var re = //;
var re = new RegExp();
search
match
test
replace
量詞:
{n,m} + * ?字符類: [^0-9]標識: i g首尾: ^ $轉義: \d \s \b \w
JS時間
var oDate = new Date();
getHours()
getMinutes()
getSeconds()
getFullYear()
getDay()
getDate()
setDate()
圖片預加載
var oImg = new Image();
經常使用方法:
getByClass()
getStyle()
posLeft()
veiwHeight()
documentHeight()
scrollY()
first()
last()
next()
pre()
經常使用的JS操做應用
加開關:bBtn
加索引:index
枚舉
遞歸
迭代
定時器
alert/console.log測試
JS運動類的應用
勻速運動
緩衝運動
彈性運動
碰撞運動
運動框架編寫/使用
Math函數應用:
max
min
abs
random
ceil
floor
round
ajax內容(經過jQuery實現便可)
什麼是ajax?
post和get的區別?
發送數據是什麼樣的?
返回數據是什麼樣的?
ajax的編寫步驟?
json怎麼取?
面向對象:
什麼是面向對象?
引用類型是什麼意思?
原型是什麼?
面向對象怎麼寫?
繼承採用的方式?
this指向理解?
數組的概念
可以理解數組的概念
可以應用普通數組,對象數組,函數數組等等。
回調函數的概念
可以使用回調函數