문자 번호 보기

function printHtmlNumber() {
	var tab = document.getElementById("tab");
	var length = 1000;
	tab.innerHTML = "";
	var row;
	var col;
	for (var i = 30, c = 0; i < length; i++, c++) {
		if (i == 30) {
			row = tab.insertRow(tab.rows.length);
			col = row.insertCell(row.cells.length);
			col.innerHTML = "&#38;#" + i + ";";
			col = row.insertCell(row.cells.length);
			col.innerHTML = "&#" + i + ";";
			continue;
		}
		if (c == 0 && i != 31) {
			row = tab.insertRow(tab.rows.length);
		}
		if (c == 10) {
			row = tab.insertRow(tab.rows.length);
			c = 0;
		}
		col = row.insertCell(row.cells.length);
		col.innerHTML = "&#38;#" + i + ";";
		col = row.insertCell(row.cells.length);
		col.innerHTML = "&#" + i + ";";
	}
}
 
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>index</title>
		<style type="text/css" >
			#tab, #tab tr {
				width: 100%;
			}
			#tab, #tab tr, #tab td {
				border: solid 2px black;
			}
			#tab td {
				width: 5%;
				text-align: center;
			}
		</style>
	</head>
	<body>
		<input type="button" onclick="printHtmlNumber()" value="print" />
		<table id="tab"></table>
	</body>
</html>
 

좋은 웹페이지 즐겨찾기