2008年6月12日 星期四

string method

indexOf()
find the pattern in the string
ex:
"abcdef".indexof("bc");

getElementById

getElementById
get html element 
ex:
html element:
input type="text", id="test",  name="abc"
javascript:
document.getElementById("test").value
access data from value

math methods

NaN:
not a number

parseInt():
convert test to integer
ex:
parseInt("1");

parseFloat()

isNaN():
ex:
var a=3;
isNaN(a);

toFixed():
ex:
a=3.333;
a.toFixed(2);
---> a=3.33

alert

show an alert box:
ex:
alert("hello");

variable , constant, function

variable:
ex:
var test=300;

constant:
ex:
const TEST= 300;


function:
ex:
function test() {

}


call two methods:
ex:
<body onload ="test(); test2();">