2008年9月14日 星期日

getElementByTagName

return an array with element with tag name, with order they appear in the page

ex: 
document.getElementByTagName("div")

innerHTML

the content of tag element
usage:  get or change the content of element
ex:
document.getElementById("test").innerHTML=  "change";

regular expression in javascript

syntax:
/  expression  /

. : match any character other than newline
\s:  match a whitespace character
\d:  match number
\w: match alphanumeric character 
^:  beginning of the string
$:  end of the string
\: escape character


quantifiers:
* :  o or more times
+:  1 or more times
?:  o or 1 time
{ n} :  n times
{min, max}:   
[abc]:  a or b or c


regular expression is a RegExp object
how to use:
ex:
var  key= /\d/;
if( key.test( "32") )
{
     alert("matched");
}

2008年8月27日 星期三

control logic ( if & switch)

switch , case, break , default:
the same as C syntax

if , else :
the same as C syntax

comment

single line: //

multiple lines: /* and */

2008年8月14日 星期四

prompt


let user enter data
ex:
prompt("what is your name",  "insert name here");


import javascript into html

<script type="text/javascript"  src="test.js"> </script>