Connecting Tech Pros Worldwide Help | Site Map

how to hide the div tag and dis[lay in the exact position on click on the another div

Newbie
 
Join Date: Sep 2009
Posts: 14
#1: Sep 7 '09
the code i tried but it not working the div displaying over the displayed one

Expand|Select|Wrap|Line Numbers
  1. <html >
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>Untitled Document</title>
  5. <link href="div1.css" rel="stylesheet" type="text/css" />
  6. <link href="div1.js" type="text/javascript" />
  7. <script type="text/javascript">
  8. function no()
  9. {
  10.     document.getElementById("1").style.display="none";
  11.     document.getElementById("2").style.display="none";
  12.     document.getElementById("3").style.display="none";
  13. }
  14. function main()
  15. {
  16.     document.getElementById("1").style.display="block";
  17.     document.getElementById("2").style.display="none";
  18.     document.getElementById("3").style.display="none";
  19. }
  20. function ma()
  21. {
  22.     document.getElementById("2").style.display="block";
  23.     document.getElementById("1").style.display="none";
  24.     document.getElementById("3").style.display="none";
  25. }
  26. function main2()
  27. {
  28.     document.getElementById("3").style.display="block";
  29.     document.getElementById("2").style.display="none";
  30.     document.getElementById("1").style.display="none";
  31. }
  32. </script>
  33. </head>
  34.  
  35. <body onload="no()">
  36. <div class="inn1" onclick="main()">
  37.     <p>for the ist button</p>
  38.     <p>&nbsp;</p>
  39. </div>
  40.  
  41.   <div class="inn2" onclick="ma()">
  42.     <p>for the ist button</p>
  43.     <p>&nbsp;</p>
  44.   </div>
  45.  
  46.   <div class="inn3" onclick="main2()">
  47.     <p>for the ist button</p>
  48.     <p>&nbsp;</p>
  49.   </div>
  50.  
  51.   <div id="main">Content for  id "main" Goes Here
  52.  
  53.   <div class="inn1" id="1">
  54.     <p>for the ist button</p>
  55.     <p>&nbsp;</p>
  56.   </div>
  57.  
  58.   <div class="inn2" id="2">
  59.     <p>for the ist button</p>
  60.     <p>&nbsp;</p>
  61.   </div>
  62.  
  63.   <div class="inn3" id="3">
  64.     <p>for the ist button</p>
  65.     <p>&nbsp;</p>
  66.   </div>
  67.  
  68.   </div>
  69. </body>
  70. </html>
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,629
#2: Sep 7 '09

re: how to hide the div tag and dis[lay in the exact position on click on the another div


IDs must not start with a number. therefore JS might ignore your ids.
Reply


Similar JavaScript / Ajax / DHTML bytes