判定瀏覽器類型:if(document.uniqueID)如果為TRUE是IE,否則非IE。
1向表中追加行
2通過JAVASCRIPT設置元素的樣式
3設置元素的CLASS屬性
4創(chuàng)建輸入元素
5向輸入元素增加事件處理程序
6創(chuàng)建單選按鈕
- 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");//非IE
- 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");