개발/PHP

버튼을 통한 아래 메뉴 혹은 탭 페이지 구현

똘또히 2017. 5. 1. 12:08

버튼을 클릭하면 같은 페이지내 다른 내용을 표시해주는 소스이다.


의외로 매우 간단하다.


[자바스크립]

<script language="javascript"> 

function btnShow(find) { 

  

 document.all.find.style.display = "none"; 

 document.all.find2.style.display = "none"; 

  

 var obj = eval("document.all." + find); 

 obj.style.display = "block"; 


</script> 


========================================== 


[html]

<a href="javascript:btnShow('find')" ><input type="button" value="버튼명"></a> 

<a href="javascript:btnShow('find2')" ><input type="button" value="버튼명"></a> 


<div  id="find" style="display:none;"> 

나타낼 내용 작성 1

</div> 

<div  id="find2" style="display:none;"> 

나타낼 내용 작성 1222

</div>