Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en" style="display: table; margin: auto;">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Task 4.1</title>
  6. </head>
  7. <body style="display: table-cell; vertical-align: middle;">
  8. <label for="txtOut">Output from Task 3.3:</label>
  9. <input type="text" id = "txtBookTitle" value="Snømannen">
  10. <button id= "btnAddBook" onclick ="btnAddBookClick()" > Legg til bok!</button>
  11. <div style="padding: 10px; margin: 10px; min-width: 500px; border: darkblue thin solid; background-color: antiquewhite">
  12. <span id="txtOut" style="white-space:nowrap;"></span>
  13. </div>
  14. <script>
  15. "use strict";
  16. const DOMTextOut = document.getElementById("txtOut");
  17. const NEWLine = "\r\n";
  18.  
  19. function printOut(aText) {
  20. if (DOMTextOut.innerText.length !== 0) {
  21. DOMTextOut.innerText += NEWLine;
  22. }
  23. DOMTextOut.innerText += aText;
  24. }
  25.  
  26. const txtBookTitle = document.getElementById("txtBookTitle");
  27.  
  28. function btnAddBookClick(){
  29. if (txtBookTitle.value === "Snømannen"){
  30. printOut("Dette er ingen bok");
  31. }else{
  32. printOut(txtBookTitle.value);
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement