サンプル9-ノードの置換の例


originalTextNode

記事へ戻る --- 愚鈍人ホーム

htmlソース

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>サンプル9-ノードの置換の例</title>
<script type="text/javascript">
	window.onload = function(){
		var cnt=0;
	    var replaceTarget = document.getElementById("replaceTarget");

		document.getElementById("btnReplaceChild").onclick = function(){
			cnt++;
			var replaceTextNode=document.createTextNode("replaceTextNode"+cnt);
			replaceTarget.replaceChild(replaceTextNode,replaceTarget.firstChild);
			return false;
		};
	};
</script>
</head>
<body>
<h1>サンプル9-ノードの置換の例</h1>
<hr />
<div id="replaceTarget">originalTextNode</div>
<form>
	<button id="btnReplaceChild">replaceChild</button>
</form>
</body>
</html>