Guest User

Untitled

a guest
Oct 21st, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. <button onClick="div1()">Try it</button>
  2. <button onClick="div2()">Try it</button>
  3. <button onClick="div3()">Try it</button>
  4.  
  5. <script>
  6. function div1() {
  7. var x = document.getElementById('myDIV');
  8. if (x.style.display === 'none') {
  9. x.style.display = 'block';
  10. } else {
  11. x.style.display = 'none';
  12. }
  13. }
  14.  
  15. function div2() {
  16. var x = document.getElementById('myDIV2');
  17. if (x.style.display === 'none') {
  18. x.style.display = 'block';
  19. } else {
  20. x.style.display = 'none';
  21. }
  22. }
  23.  
  24. function div3() {
  25. var x = document.getElementById('myDIV3');
  26. if (x.style.display === 'none') {
  27. x.style.display = 'block';
  28. } else {
  29. x.style.display = 'none';
  30. }
  31. }
  32. </script>
  33.  
  34. <div id="rightSideDiv" ></div>
  35. <input type="hidden" id="myHiddenField1" value="<b> Info of div 1</b>" />
  36. <input type="hidden" id="myHiddenField2" value="<b> Info of div 2</b>" />
  37. <input type="hidden" id="myHiddenField3" value="<b> Info of div 3</b>" />
  38.  
  39. <button onClick="doDisplay('myHiddenField1')">Try it</button>
  40. <button onClick="doDisplay('myHiddenField2')">Try it</button>
  41. <button onClick="doDisplay('myHiddenField3')">Try it</button>
  42.  
  43. <script>
  44. function doDisplay(hiddenFileldID) {
  45. var x = document.getElementById(hiddenFileldID).value;
  46. document.getElementById("rightSideDiv").innerHTML = x;
  47. }
  48. </script>
Add Comment
Please, Sign In to add comment