易截截图软件、单文件、免安装、纯绿色、仅160KB

javascript操作DOM

1.创建节点并添加内容:使用的方法:createElement和createTextNode
<html>
<head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>HTML DOM</title>
        <script type=text/javascript>
function Message()
        {
         var op=document.createElement("p");
         var oText=document.createTextNode("hello world!");
         op.appendChild(oText);
         document.body.appendChild(op);
        }
        </script>
</head>
<body onload="Message();">
</body>
</html>
2,删除节点 方法:getElementsByTagName和removeChild
<html>
<head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>HTML DOM</title>
        <script type=text/javascript>
        function removeMessage()
        {
         var op=document.body.getElementsByTagName("p")[0];
         op.parentNode.removeChild(op);
        }
        </script>
</head>
<body onload="removeMessage();">
        <p>hello world!</p>
</body>
</html>
3.替换节点 方法replace(new,old)
<html>
<head>
      <meta htt


相关文档:

JavaScript HashTable

/**
* 自己的 HashTable
* 愿脚本神力与你同在
*/
function HashTable(){
var values = {};

/** 将值插入 HashTable 中 **/
this.put = function(key, value){
if(key in values){
return false;
}
values[key] = value;
}
/** 根据 key 返回 value **/
this.find = function(key){
ret ......

javascript判断变量类型的自定义函数

通常用typeof来判断js变量的类型,但很多时候仅仅typeof满足不了要求的。
我写了一个自定义函数来做这个事,判断的比较全面了。
New
function
varType(v){

  if
(
typeof
v===
"object"
){

    if
(v===
null
)
return
'null'
;

    if
(v.
constructo ......

javascript event对象 与 jquery event 解析(转)

转自:http://www.cnblogs.com/mslove/
描述
event代表事件的状态,例如触发event对象的元素、鼠标的位置及状态、按下的键等等。
event对象只在事件发生的过程中才有效。
event的某些属性只对特定的事件有意义。比如,fromElement 和 toElement 属性只对 onmouseover 和 onmouseout 事件有意义。
例子
下面的例子检查 ......

Javascript Closures

Javascript Closures
Introduction
The Resolution of Property Names on Objects
Assignment of Values
Reading of Values
Identifier Resolution, Execution Contexts and Scope Chains
The Execution Context
Scope chains and [[scope]]
Identifier Resolution
Closures
Automatic Garbage Collecti ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号