Created
January 18, 2012 04:21
-
-
Save nakunaru/1630951 to your computer and use it in GitHub Desktop.
JQueryでTABLEを生成するサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>JQuery Create Table samle</title> | |
<script type="text/javascript" src="../htdocs/js/jquery.min.js"></script> | |
<style> | |
.table{ | |
border:1px solid #000000; | |
border-collapse:collapse; | |
border-spacing:0; | |
padding:0; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="tabarea"> | |
</div> | |
<script language="javascript"> | |
// table create | |
rows = 5; | |
cols = 5; | |
$('#tabarea').append('<table id="tab1" class="table">'); | |
for(i=0; i<rows; i++){ | |
$('#tabarea > table').append($('<tr>')); | |
for(j=0; j<cols; j++){ | |
$("#tab1 > tbody > tr:last").append($('<td class="table" id="r' + i + 'c' + j + '">').text('r' + i + 'c' + j)); | |
} | |
} | |
// get rows and cells | |
alert("rows:" + tab1.rows.length); | |
alert("cells:" + tab1.rows[0].cells.length); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment