<html>
<head>
<title>textNode 변경하기</title>
<script type="text/javascript">
function changeBookable(bookableId, stateStr) {
removeBookableTextNode(bookableId);
addBookableTextNode (bookableId, stateStr);
}
function removeBookableTextNode(value1)
{
var bookStateDiv = document.getElementById("bookState");
document.getElementById("bookable"+value1).removeChild(bookStateDiv);
}
function addBookableTextNode(value1, value2)
{
var divElement = document.createElement("div");
divElement.id = "bookState";
var attrValue = document.createTextNode(value2);
divElement.appendChild(attrValue);
document.getElementById("bookable"+value1).appendChild(divElement);
}
</script>
</head>
<body>
<div id="bookable12401001"><div id="bookState">예약가능1</div></div>
<div id="bookable12401002"><div id="bookState">예약가능2</div></div>
<div id="bookable12401003"><div id="bookState">예약가능3</div></div>
<div id="bookable12401004"><div id="bookState">예약가능4</div></div>
<button onclick="changeBookable(12401001, '예약중')">예약중</button>
<button onclick="changeBookable(12401001, '예약가능')">예약가능</button>
</body>
</html>
[출처] textNode 변경하기|작성자 들닢
'programming > java' 카테고리의 다른 글
Map iterator 예제 (0) | 2012.03.20 |
---|---|
톰캣6 windows 64bit 설치 (0) | 2012.03.20 |
iframe 사이즈 늘리기(3) (0) | 2012.03.20 |
data 중복 제거 (0) | 2012.03.20 |
내가 만든 bar Chart (0) | 2012.03.20 |