Home > Web Front-end > JS Tutorial > Create a table and add events_javascript skills

Create a table and add events_javascript skills

WBOY
Release: 2016-05-16 19:27:18
Original
1115 people have browsed it

[Ctrl A select all Note: If you need to introduce external Js, you need to refresh to execute
]<script> //建一个row行,col列的表格 var tbl, tbody, tr, td, text, i,j,row,col; row=10;col=15; var theDoc = document; var theBody = theDoc.body; tbl = theDoc.createElement("TABLE"); tbl.border = "1"; tbl.setAttribute("id","abc"); tbody = theDoc.createElement("TBODY"); tbl.insertBefore(tbody, null); theBody.insertBefore(tbl, null); for (i=0; i<row; i++) { tr = theDoc.createElement("TR"); for (j=0;j<col;j++) { td = theDoc.createElement("TD"); text = theDoc.createTextNode("Text"); tbody.insertBefore(tr, null); tr.insertBefore(td, null); td.insertBefore(text, null); } } var a="aaa"; var b="bbb"; document.getElementById("abc").attachEvent("onclick",function(){alert(a);alert(b)}); </script>
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template