最近,看了AJAX的开发基础这本书.发现有几行代码对我们编程也有好处.具体如下 :
1向表中追加行
2通过JAVASCRIPT设置元素的样式
3设置元素的CLASS属性
4创建输入元素
5向输入元素增加事件处理程序
6创建单选按钮
1<table id="MyTable>
<tbody id="MyTableBody"></tbody>
</table>
var cell = documentcreateElement("td").appendChild(document.createTextNode("foo"));
var row = document.createElement("tr").appendChild(cell);
document.getElementById("MyTableBoyd").appendChild(row);
2
var spanElement = document.getElementById("myspan");
//spanElement.setAttribute("style","font-weight:bold;color:red");
spanElement.style.cssText="font-weight:bold;color:red";
3
element.setAttribute("class","stylename");
element.setAttribute("classname","stylename");//IE
4创建输入元素
var button = document.createElement("input");
button.setAttribute("type","button");
document.getElementById("form").appendChild(button);
5
var element = document.getElementById("ee");
element.onclick=function(){todo();};
6
var ration = document.createElement("<input type='radio' name='radioa' value='checked'>);//ie
vat radion = document.createElement("input");
radion .setAttribute("type","radio");
radion.setAttribute("name","radionsss");
radion.setAttribute("value","checked");
另外,判定IE是不是:if(document.uniqueID)如果为TRUE,IE,否则是非IE