jQueryで、HTMLのテーブルのセルの高さをHTMLのheight属性で変更します。
【手順】
1.「jQuery1.8.1のダウンロード方法」の手順で、jQuery1.8.1をダウンロードしておきます。
2.「011-TableCellHeightJQuery.html」というファイルを作成。
3.「011-TableCellHeightJQuery.html」を以下の様に入力。
<html>
<head>
<script type="text/javascript" src="./jquery-1.8.1.min.js"></script>
<script type="text/javascript">
$(function(){
$("#button1").click(function(){
$("#table1 tr td").attr("height", "100");
})
$("#button2").click(function(){
$("#table1 tr td").attr("height", "200");
})
})
</script>
</head>
<body>
<table id="table1" border="1">
<tr>
<td height="100">セル1-1</td>
<td height="100">セル1-2</td>
</tr>
<tr>
<td height="100">セル2-1</td>
<td height="100">セル2-2</td>
</tr>
</table>
<input id="button1" type="button" value="100px">
<input id="button2" type="button" value="200px">
</body>
</html>
4.ダウンロードした「jquery-1.8.1.min.js」と「011-TableCellHeightJQuery.html」を同一ディレクトリに配置します。
5.「011-TableCellHeightJQuery.html」をブラウザで開きます。
6.以下の様に表示されれば成功です。
以上です。
-01.png)
0 件のコメント:
コメントを投稿
注: コメントを投稿できるのは、このブログのメンバーだけです。