「JavaScript オブジェクトのプロパティ確認」の版間の差分
ナビゲーションに移動
検索に移動
(ページの作成:「==JavaScript オブジェクトのプロパティ確認== [JavaScript] ===オブジェクトのプロパティを概観する === <html> <head> <script type="text…」) |
|||
| 2行目: | 2行目: | ||
[JavaScript] | [JavaScript] | ||
===オブジェクトのプロパティを概観する === | ===オブジェクトのプロパティを概観する === | ||
| − | + | <html> | |
| − | + | <head> | |
| − | + | <script type="text/javascript"> | |
// オブジェクトのプロパティ確認 | // オブジェクトのプロパティ確認 | ||
function inspect(sel) { | function inspect(sel) { | ||
| − | var html = " | + | var html = "<table border=1>"; |
| − | html += " | + | html += "<tr><th>key</th><th>value</th></tr>"; |
for (k in sel) { | for (k in sel) { | ||
| − | html += " | + | html += "<tr><td>" + k + "</td><td>" + sel[k] + "</td></tr>"; |
} | } | ||
| − | html += " | + | html += "</table>"; |
w = window.open(); | w = window.open(); | ||
w.document.write(html); | w.document.write(html); | ||
w.document.close(); | w.document.close(); | ||
} | } | ||
| − | + | </script> | |
| − | + | </head> | |
| − | + | <body> | |
| − | + | <select onchange="inspect(this)"> | |
| − | + | <option value="1">1</option> | |
| − | + | <option value="2">2</option> | |
| − | + | <option value="3">3</option> | |
| − | + | </select> | |
| − | + | </body> | |
| − | + | </html> | |
2020年2月15日 (土) 07:42時点における版
JavaScript オブジェクトのプロパティ確認
[JavaScript]
オブジェクトのプロパティを概観する
<html>
<head>
<script type="text/javascript">
// オブジェクトのプロパティ確認
function inspect(sel) {
var html = "<table border=1>";
html += "<tr><th>key</th><th>value</th></tr>";
for (k in sel) {
html += "<tr><td>" + k + "</td><td>" + sel[k] + "</td></tr>";
}
html += "</table>";
w = window.open();
w.document.write(html);
w.document.close();
}
</script>
</head>
<body>
<select onchange="inspect(this)">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</body>
</html>
© 2006 矢木浩人