4月 20th, 2008at 16:21
Tags: Javascript, Web
Javascriptメモ
head要素内に記述する場合
<html><head><title>タイトル</title><meta http-equiv="Content-Script-Type" content="text/javascript"><script type="text/javascript"><!-- // ここに処理を記述// --></script></head><body />
外部ファイルに記述する場合
拡張子が「js」のファイルを用意します。そしてそのファイルにJavascriptを記述し、外部ファイルとしてHTML内で読み込むことも可能。
// test.jsfunction test(){ alert("テストです");}
<html><head><title>JavaScript Sample</title><script type="text/javascript" src="test.js" /></head><body />
THをJavascriptでインサートしたいんだけどできないのだ。
http://www.y-adagio.com/public/standards/tr_dom1/level-one-html.html
function addRule(tableName){ table = document.getElementById(tableName); row = table.insertRow(table.rows.length); cell = row.insertCell(); cell.innerHTML = "aaa";
cell = row.insertCell(); cell.innerHTML = "bbb";
newElement = document.createElement('th'); newValue = document.createTextNode('中身'); appendElement = newElement.appendChild(newValue); row.appendChild(appendElement);
alert(row.hasChildNode());
newElement = document.createElement('td'); newValue = document.createTextNode('中身'); appendElement = newElement.appendChild(newValue); row.appendChild(appendElement);
alert();
/** if(table != null){ addHTML = "<tr><th>条件</th><td><input type='text' value='' class='widthRegular'></td></tr>"; addHTML += "<tr><th>あて先URL</th><td><input type='text' value='' class='widthWide'></td></tr>"; table.innerHTML = addHTML; }else{ alert("引数エラー"); } */}
ランダムの使い方
1から3のランダムな自然数は
Math.floor(Math.random()*3+1)




