아는 것이 좋은 것이다.

[JavaScript] 게시판 상세내용 열고 닫기 본문

JavaScript

[JavaScript] 게시판 상세내용 열고 닫기

start0 2014. 5. 15. 15:59
<script type="text/javascript">
<!--
function open_detail(obj){
	var reset = document.getElementsByClassName("comment a").length;
	//alert(reset);

	for(i=1; i <= reset; i++){
		//alert(document.getElementById('review' + i) + ", " + document.getElementById('review_re' + i));
		//document.getElementById('review'+ i).style.display = 'none';
		//document.getElementById('review_re'+ i).style.display = 'none';


	}
		//alert(document.getElementById('review'+ obj).style.display);
		if (document.getElementById('review'+ obj).style.display == "")
		{
			document.getElementById('review'+ obj).style.display = 'none';
			document.getElementById('review_re'+ obj).style.display = 'none';

		}else{
			document.getElementById('review'+ obj).style.display = '';
			document.getElementById('review_re'+ obj).style.display = '';
		}
	//document.getElementById('review'+ obj).style.display = '';
	//document.getElementById('review_re'+ obj).style.display = '';
}	
//-->
</script>
<table class="detailList" border="1" cellspacing="2" cellpadding="0" width="600">
<colgroup>
<col width="10%">
<col width="55%">
<col width="20%">
<col width="15%">
<col width="10%">
</colgroup>
<thead>
<tr>
    <th>번호</th>
    <th>제목</th>
    <th>작성자</th>
    <th>등록일</th>
    <th>조회수</th>
</tr>
</thead>
<tbody>

<tr>
    <th>6</th>
    <td><a href="JavaScript:;" onclick="JavaScript: open_detail('1');">제목1</a></td>
    <th>작성자1</th>
    <th>2014.05.15</th>
    <th>526</th>
</tr>
<tr class="comment a" id="review1" style="display: none;">
    <th></th>
    <td colspan="4">상세내용1</td>
</tr>

<tr>
    <th>5</th>
    <td><a href="JavaScript:;" onclick="JavaScript: open_detail('2');">제목2</a></td>
    <th>작성자2</th>
    <th>2014.05.15</th>
    <th>526</th>
</tr>
<tr class="comment a" id="review2" style="display: none;">
    <th></th>
    <td colspan="4">상세내용2</td>
</tr>

<tr>
    <th>4</th>
    <td><a href="JavaScript:;" onclick="JavaScript: open_detail('3');">제목3</a></td>
    <th>작성자3</th>
    <th>2014.05.15</th>
    <th>526</th>
</tr>
<tr class="comment a" id="review3" style="display: none;">
    <th></th>
    <td colspan="4">상세내용3</td>
</tr>

<tr>
    <th>3</th>
    <td><a href="JavaScript:;" onclick="JavaScript: open_detail('4');">제목4</a></td>
    <th>작성자4</th>
    <th>2014.05.15</th>
    <th>526</th>
</tr>
<tr class="comment a" id="review4" style="display: none;">
    <th></th>
    <td colspan="4">상세내용4</td>
</tr>

<tr>
    <th>2</th>
    <td><a href="JavaScript:;" onclick="JavaScript: open_detail('5');">제목5</a></td>
    <th>작성자5</th>
    <th>2014.05.15</th>
    <th>526</th>
</tr>
<tr class="comment a" id="review5" style="display: none;">
    <th></th>
    <td colspan="4">상세내용5</td>
</tr>

</tbody>
</table>
Comments