JavaScript 定時器
? ? ? ?單次定時 setTimeout(fn,2000);
? ? ? ? 多次定時 setInterval(fn,2000);
? ? ? ?停止多次定時 clearInterval(timer);
? ? ? ? 停止單次定時 clearTimeout(timer);
? ? 實例:
? ? 使用單次和多次定時寫倒計時坪蚁。
通過js獲取或者修改元素的css樣式
? ? ? ? 在w3c中找到JavaScript的語法
? ? ? ? box.style.width=(parseInt(box.style.width)+10)+'px';
? ? ? ? box.style.backgroundColor='red';
命名介紹
? ? ? ? backgroundColor小駝峰命名法
? ? ? ? BackgroundColor 大駝峰
? ? ? ? background-color匈牙利命名法
數(shù)學運算
1扑毡、document.write(Math); //數(shù)學運算對象
2、document.write(Math.PI);//PI是數(shù)學對象的一個屬性
3、document.write(Math.abs(100.21));//絕對值
4捣郊、document.write(Math.pow(2,4));//求次方2的4次方
5非剃、document.write(Math.sqrt(100));//開平方
6、document.write(Math.round(100.21));//四舍五入
7宙暇、document.write(Math.floor(100.21));//舍一取整
8输枯、document.write(Math.ceil(100.21));//進一取整
9、document.write(Math.max(100.21,334,344,34));//求最大值
10客给、document.write(Math.min(100.21,343,543));//求最小值
11用押、document.write(Math.random()); //取隨機數(shù) 0--1
取隨機數(shù)
1.取0-9隨機數(shù): Math.floor(Math.random()*10);
2.取0-17隨機數(shù):Math.floor(Math.random()*18);
3.取0-10隨機數(shù):Math.round(Math.random()*11);
取優(yōu)質(zhì)隨機數(shù)
4.0-9優(yōu)質(zhì)隨機數(shù)? Math.floor((Math.random()*1000000)%10);
5.0-17優(yōu)質(zhì)隨機數(shù)? Math.floor((Math.random()*1000000)%18);
6.9-17優(yōu)質(zhì)隨機數(shù)? Math.floor((Math.random()*1000000)%9+9);
Boolean對象
? ? ? ? var a? = true;
? ? ? ? var b = new Boolean(1);
? ? ? ? var c =? Boolean('abcd');
? ? ? ? typeof a
? ? ? ? typeof b
? ? ? ? typeof c
? ? ? ? b.valueOf()? ? //返回boolean對象的原始值? --typeof
? ? ? ? b.toString()? //轉(zhuǎn)為字符串
Number對象
1、屬性
? ? ? ? MAX_VALUE? ? ? 可表示的最大的數(shù)
? ? ? ? Number.MAX_VALUE
? ? ? ? MIN_VALUE? ? ? 可表示的最小的數(shù)
? ? ? ? Number.MIN_VALUE
? ? ? ? NaN ? ? ? ? ? ? ? ? ? 非數(shù)字值
2靶剑、方法
? ? ? ? toString()? ? ? ? ? 轉(zhuǎn)換為指定的進制數(shù)
? ? ? ? 50.toString(2)
? ? ? ? toFixed()? ? ? ? ? 轉(zhuǎn)換為指定小數(shù)點位數(shù)的數(shù)值
? ? ? ? 12.2343.toFixed(1)? //參數(shù)0-20
? ? ? ? toExponential()? ? 轉(zhuǎn)換為科學計數(shù)法
? ? ? ? 12.434343.toExponential()
? ? ? ? toPrecision()? ? ? 轉(zhuǎn)換為指定長度的數(shù)值
? ? ? ? 1000.121323123.toPrecision()? ? //參數(shù)1-21
String對象
? ? ? ? 字符串比較
? ? ? ? (ASCII碼表)? Unicode進制
1蜻拨、屬性
? ? ? ? string.length; 字符串長度(空格算一個字符)
2池充、String方法
? ? ? ? charAt() //返回指定位置的字符
? ? ? ? concat() //連接字符串
? ? ? ? charCodeAt() //返回指定字符的unicode編碼
? ? ? ? fromCharCode() //將unicode編碼轉(zhuǎn)為字符
? ? ? ? indexOf() //搜索指定字符(首次出現(xiàn)) 沒有返回-1
? ? ? ? lastIndexOf() //從后往前搜索字符串
? ? ? ? slice() //字符串截取 start,end
? ? ? ? match() //正則
? ? ? ? search()
? ? ? ? str.replace
? ? ? ? substr() //截取字符串 start,length
? ? ? ? substring() //和slice用法相同
? ? ? ? toLowerCase() //轉(zhuǎn)換為小寫
? ? ? ? toUpperCase() //轉(zhuǎn)換為大寫
? ? ? ? split() //分割字符串
? ? ? ? 實例:嘗試將匈牙利命名法 改成 小駝峰命名法
====================================
以下內(nèi)容自己下去看
anchor() //給字符串添加一個錨點
big() // 用大號字體顯示字符串
blink() //添加一個blink標簽
fixed() //以打字機文本顯示字符串
fontcolor() //以指定顏色顯示字符串
fontsize() //以指定大小顯示字符串
small() //小型字體
italics() //斜體
sub() //下標
sup() //上標
toLocaleLowerCase()
toLocaleUpperCase()
作業(yè)
實例一:進度條
實例二: 點名器1 點名器2
實例三: 距離世界末日還有 10:10:10
實例四:1.jpg中的js效果
實例五:不重復的點名器
實例六:小球的下落(開始暫停)
實例七:來回滾動的小球