1.定時(shí)器
1.setTimeout(Expression,DelayTime),
在DelayTime過(guò)后,將執(zhí)行一次Expression,
setTimeout 運(yùn)用在延遲一段時(shí)間豪治,再進(jìn)行某項(xiàng)操作座掘。
setTimeout("",time) 設(shè)置一個(gè)超時(shí)對(duì)象**
2.setInterval(expression,delayTime),
每個(gè)DelayTime,都將執(zhí)行Expression.
常晨罚可用于刷新表達(dá)式.setInterval("",time)
設(shè)置一個(gè)超時(shí)對(duì)象
SetInterval為自動(dòng)重復(fù)绑洛,setTimeout不會(huì)重復(fù)敞贡。
clearTimeout(對(duì)象) 清除已設(shè)置的setTimeout對(duì)象
clearInterval(對(duì)象) 清除已設(shè)置的setInterval對(duì)象
2.eval()將字符串轉(zhuǎn)為可執(zhí)行的值
3.函數(shù)
1.函數(shù)聲明
特點(diǎn):1.聲明后不會(huì)執(zhí)行,需要調(diào)用.2.關(guān)鍵字function;
類型: 1.參數(shù) 2 返回值
2.函數(shù)調(diào)用
直接編寫(xiě)函數(shù)名,后面緊跟小括號(hào)
3.函數(shù)表達(dá)式
使用變量保存一個(gè)函數(shù)
實(shí)際上是匿名函數(shù) 可以添加函數(shù)名
4.自調(diào)用函數(shù)
(function(){
)()
5.函數(shù)參數(shù)屬性 arguments:代表參數(shù)的集合
6.參數(shù):
參數(shù)類型:1隱藏參數(shù):參數(shù)調(diào)用時(shí)的值 .2顯示參數(shù),定義時(shí)寫(xiě)的參數(shù)
默認(rèn)參數(shù):函數(shù)調(diào)用時(shí)缺少參數(shù),默認(rèn)是null
7.閉包:
var add = (function() {
var count = 0;
return function(){
return +count;
}
}
4.字符串操作
anchor() 創(chuàng)建 HTML 錨。
big() 用大號(hào)字體顯示字符串。
blink() 顯示閃動(dòng)字符串昼伴。
bold() 使用粗體顯示字符串。
charAt() 返回在指定位置的字符伪窖。
charCodeAt() 返回在指定的位置的字符的 Unicode 編碼。
concat() 連接字符串譬嚣。
fixed() 以打字機(jī)文本顯示字符串钢颂。
fontcolor() 使用指定的顏色來(lái)顯示字符串。
fontsize() 使用指定的尺寸來(lái)顯示字符串拜银。
fromCharCode() 從字符編碼創(chuàng)建一個(gè)字符串殊鞭。
indexOf() 檢索字符串。
italics() 使用斜體顯示字符串尼桶。
lastIndexOf() 從后向前搜索字符串操灿。
link() 將字符串顯示為鏈接。
localeCompare() 用本地特定的順序來(lái)比較兩個(gè)字符串泵督。
match() 找到一個(gè)或多個(gè)正則表達(dá)式的匹配趾盐。
replace() 替換與正則表達(dá)式匹配的子串。
search() 檢索與正則表達(dá)式相匹配的值幌蚊。
slice() 提取字符串的片斷谤碳,并在新的字符串中返回被提取的部分溃卡。
small() 使用小字號(hào)來(lái)顯示字符串溢豆。
split() 把字符串分割為字符串?dāng)?shù)組。
strike() 使用刪除線來(lái)顯示字符串瘸羡。
sub() 把字符串顯示為下標(biāo)漩仙。
substr() 從起始索引號(hào)提取字符串中指定數(shù)目的字符。
substring() 提取字符串中兩個(gè)指定的索引號(hào)之間的字符犹赖。
sup() 把字符串顯示為上標(biāo)队他。
toLocaleLowerCase() 把字符串轉(zhuǎn)換為小寫(xiě)。
toLocaleUpperCase() 把字符串轉(zhuǎn)換為大寫(xiě)峻村。
toLowerCase() 把字符串轉(zhuǎn)換為小寫(xiě)麸折。
toUpperCase() 把字符串轉(zhuǎn)換為大寫(xiě)。
toSource() 代表對(duì)象的源代碼粘昨。
toString() 返回字符串垢啼。
valueOf() 返回某個(gè)字符串對(duì)象的原始值。
5.Date對(duì)象
Date() 返回當(dāng)日的日期和時(shí)間张肾。
參數(shù)形式
- 1)new Date("month dd,yyyy hh:mm:ss");
- 2)new Date("month dd,yyyy");
- 3)new Date(yyyy,mth,dd,hh,mm,ss);
- 4)new Date(yyyy,mth,dd);
- 5)new Date(ms);
getDate() 從 Date 對(duì)象返回一個(gè)月中的某一天 (1 ~ 31)芭析。
getDay() 從 Date 對(duì)象返回一周中的某一天 (0 ~ 6)。
getMonth() 從 Date 對(duì)象返回月份 (0 ~ 11)吞瞪。
getFullYear() 從 Date 對(duì)象以四位數(shù)字返回年份馁启。
getHours() 返回 Date 對(duì)象的小時(shí) (0 ~ 23)。
getMinutes() 返回 Date 對(duì)象的分鐘 (0 ~ 59)芍秆。
getSeconds() 返回 Date 對(duì)象的秒數(shù) (0 ~ 59)惯疙。
getMilliseconds() 返回 Date 對(duì)象的毫秒(0 ~ 999)翠勉。
getTime() 返回 1970 年 1 月 1 日至今的毫秒數(shù)。
getTimezoneOffset() 返回本地時(shí)間與格林威治標(biāo)準(zhǔn)時(shí)間 (GMT) 的分鐘差螟碎。
getUTCDate() 根據(jù)世界時(shí)從 Date 對(duì)象返回月中的一天 (1 ~ 31)眉菱。
getUTCDay() 根據(jù)世界時(shí)從 Date 對(duì)象返回周中的一天 (0 ~ 6)。
getUTCMonth() 根據(jù)世界時(shí)從 Date 對(duì)象返回月份 (0 ~ 11)掉分。
getUTCFullYear() 根據(jù)世界時(shí)從 Date 對(duì)象返回四位數(shù)的年份俭缓。
getUTCHours() 根據(jù)世界時(shí)返回 Date 對(duì)象的小時(shí) (0 ~ 23)。
getUTCMinutes() 根據(jù)世界時(shí)返回 Date 對(duì)象的分鐘 (0 ~ 59)酥郭。
getUTCSeconds() 根據(jù)世界時(shí)返回 Date 對(duì)象的秒鐘 (0 ~ 59)华坦。
getUTCMilliseconds() 根據(jù)世界時(shí)返回 Date 對(duì)象的毫秒(0 ~ 999)。
parse() 返回1970年1月1日午夜到指定日期(字符串)的毫秒數(shù)不从。
setDate() 設(shè)置 Date 對(duì)象中月的某一天 (1 ~ 31)惜姐。
setMonth() 設(shè)置 Date 對(duì)象中月份 (0 ~ 11)。
setFullYear() 設(shè)置 Date 對(duì)象中的年份(四位數(shù)字)椿息。
setHours() 設(shè)置 Date 對(duì)象中的小時(shí) (0 ~ 23)歹袁。
setMinutes() 設(shè)置 Date 對(duì)象中的分鐘 (0 ~ 59)。
setSeconds() 設(shè)置 Date 對(duì)象中的秒鐘 (0 ~ 59)寝优。
setMilliseconds() 設(shè)置 Date 對(duì)象中的毫秒 (0 ~ 999)条舔。
setTime() 以毫秒設(shè)置 Date 對(duì)象。
setUTCDate() 根據(jù)世界時(shí)設(shè)置 Date 對(duì)象中月份的一天 (1 ~ 31)乏矾。
setUTCMonth() 根據(jù)世界時(shí)設(shè)置 Date 對(duì)象中的月份 (0 ~ 11)孟抗。
setUTCFullYear() 根據(jù)世界時(shí)設(shè)置 Date 對(duì)象中的年份(四位數(shù)字)。
setUTCHours() 根據(jù)世界時(shí)設(shè)置 Date 對(duì)象中的小時(shí) (0 ~ 23)钻心。
setUTCMinutes() 根據(jù)世界時(shí)設(shè)置 Date 對(duì)象中的分鐘 (0 ~ 59)凄硼。
setUTCSeconds() 根據(jù)世界時(shí)設(shè)置 Date 對(duì)象中的秒鐘 (0 ~ 59)。
setUTCMilliseconds() 根據(jù)世界時(shí)設(shè)置 Date 對(duì)象中的毫秒 (0 ~ 999)捷沸。
toSource() 返回該對(duì)象的源代碼摊沉。
toString() 把 Date 對(duì)象轉(zhuǎn)換為字符串。
toTimeString() 把 Date 對(duì)象的時(shí)間部分轉(zhuǎn)換為字符串痒给。
toDateString() 把 Date 對(duì)象的日期部分轉(zhuǎn)換為字符串说墨。
toUTCString() 根據(jù)世界時(shí),把 Date 對(duì)象轉(zhuǎn)換為字符串侈玄。
toLocaleString() 根據(jù)本地時(shí)間格式婉刀,把 Date 對(duì)象轉(zhuǎn)換為字符串。
toLocaleTimeString() 根據(jù)本地時(shí)間格式序仙,把 Date 對(duì)象的時(shí)間部分轉(zhuǎn)換為字符串突颊。
toLocaleDateString() 根據(jù)本地時(shí)間格式,把 Date 對(duì)象的日期部分轉(zhuǎn)換為字符串。
UTC() 根據(jù)世界時(shí)返回 1970 年 1 月 1 日 到指定日期的毫秒數(shù)律秃。
valueOf() 返回 Date 對(duì)象的原始值爬橡。
6.Math對(duì)象
Math 對(duì)象屬性
E 返回算術(shù)常量 e,即自然對(duì)數(shù)的底數(shù)(約等于2.718)棒动。
LN2 返回 2 的自然對(duì)數(shù)(約等于0.693)糙申。
LN10 返回 10 的自然對(duì)數(shù)(約等于2.302)。
LOG2E 返回以 2 為底的 e 的對(duì)數(shù)(約等于 1.414)船惨。
LOG10E 返回以 10 為底的 e 的對(duì)數(shù)(約等于0.434)柜裸。
PI 返回圓周率(約等于3.14159)。
SQRT1_2 返回返回 2 的平方根的倒數(shù)(約等于 0.707)粱锐。
SQRT2 返回 2 的平方根(約等于 1.414)疙挺。
Math 對(duì)象方法
abs(x) 返回?cái)?shù)的絕對(duì)值。
ceil(x) 對(duì)數(shù)進(jìn)行上舍入怜浅。
floor(x) 對(duì)數(shù)進(jìn)行下舍入铐然。
log(x) 返回?cái)?shù)的自然對(duì)數(shù)(底為e)。
max(x,y) 返回 x 和 y 中的最高值恶座。
min(x,y) 返回 x 和 y 中的最低值搀暑。
pow(x,y) 返回 x 的 y 次冪。
random() 返回 0 ~ 1 之間的隨機(jī)數(shù)跨琳。
round(x) 把數(shù)四舍五入為最接近的整數(shù)自点。
sqrt(x) 返回?cái)?shù)的平方根。
valueOf() 返回 Math 對(duì)象的原始值湾宙。
7.自定義屬性
Js操作自定義屬性的方法:
var testEle = document.getElementByIdx_x("test")
testEle.setAttribute("test","aaa"); // 設(shè)置
testEle.getAttribute("test")樟氢; //獲取
testEle.attributes["test"].nodeValue; // 獲取
Jquery操作自定義屬性的方法:
$("#test").attr("test","aaa") // 設(shè)置
$("#test").removeAttr("test") // 刪除
var testAttr = "ddd";
$('#test[test="'+ testAttr +'"]')