Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. <!DOCTYPE html>
  2.  
  3. <html>
  4. <head>
  5. <title>SampleApp</title>
  6.  
  7.  
  8. <style>
  9.  
  10. .stepperInput {
  11. /**
  12. * Setting display to flex makes this container lay
  13. * out its children using flexbox. By default, it
  14. * orders items horizontally, top-aligned.
  15. * This has a similar effect to setting the children
  16. * to have display: inline-block.
  17. */
  18. display: flex;
  19. }
  20.  
  21. .stepperInput__input {
  22. border-left: 0;
  23. border-right: 0;
  24. width: 60px;
  25. text-align: center;
  26. }
  27.  
  28. .button {
  29. cursor: pointer;
  30. padding: 5px 15px;
  31. color: #FFFFFF;
  32. background-color: #4EBBE4;
  33. font-size: 12px;
  34. border: 1px solid #16A2D7;
  35. border-radius: 4px;
  36. }
  37.  
  38. .button--addOnLeft {
  39. border-top-right-radius: 0;
  40. border-bottom-right-radius: 0;
  41. }
  42.  
  43. .button--addOnRight {
  44. border-top-left-radius: 0;
  45. border-bottom-left-radius: 0;
  46. }
  47.  
  48. .input {
  49. border: 1px solid #D7DBDD;
  50. padding: 0 10px;
  51. border-radius: 0;
  52. box-shadow: none;
  53. }
  54.  
  55.  
  56.  
  57. </style>
  58. </head>
  59.  
  60. <body>
  61.  
  62. <div class="stepperInput">
  63. <button class="button button--addOnLeft">-</button>
  64. <input type="text" placeholder="Age" value="32" class="input stepperInput__input"/>
  65. <button class="button button--addOnRight">+</button>
  66. </div>
  67.  
  68.  
  69. <script>
  70. var buttonUp = document.querySelector(".button--addOnRight");
  71. var numberDisplay = document.querySelector(".stepperInput__input");
  72. var buttonDown = document.querySelector(".button--addOnLeft");
  73.  
  74. buttonUp.addEventListener("click", function()
  75. {
  76.  
  77. numberDisplay.value = parseInt(numberDisplay.value) + 1;
  78.  
  79. } );
  80.  
  81. buttonDown.addEventListener("click", function()
  82. {
  83.  
  84. numberDisplay.value = parseInt(numberDisplay.value) - 1;
  85.  
  86. } );
  87.  
  88.  
  89. </script>
  90. </body>
  91. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement