jQueryで、HTMLのテーブルのセルのボーダー(枠線)の色をHTMLのbordercolor属性で変更します。
【手順】
1.「jQuery1.8.1のダウンロード方法」の手順で、jQuery1.8.1をダウンロードしておきます。
2.「020-TableCellBorderColorJQuery.html」というファイルを作成。
3.「020-TableCellBorderColorJQuery.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("borderColor", "red");
})
$("#button2").click(function(){
$("#table1 tr td").attr("borderColor", "blue");
})
})
</script>
</head>
<body>
<table id="table1" border="1">
<tr>
<td bordercolor="red">セル1-1</td>
<td>セル1-2</td>
</tr>
<tr>
<td>セル2-1</td>
<td>セル2-2</td>
</tr>
</table>
<input id="button1" type="button" value="red">
<input id="button2" type="button" value="blue">
</body>
</html>
4.ダウンロードした「jquery-1.8.1.min.js」と「020-TableCellBorderColorJQuery.html」を同一ディレクトリに配置します。
5.「020-TableCellBorderColorJQuery.html」をブラウザで開きます。
6.以下の様に表示されれば成功です。
以上です。
%E3%81%AE%E8%89%B2%E3%82%92%E5%A4%89%E6%9B%B4%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95(HTML%E3%81%AEbordercolor%E5%B1%9E%E6%80%A7)-01.png)
0 件のコメント:
コメントを投稿
注: コメントを投稿できるのは、このブログのメンバーだけです。