Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en" style="display: table; margin: auto;">
- <head>
- <meta charset="UTF-8">
- <title>Task 4.1</title>
- </head>
- <body style="display: table-cell; vertical-align: middle;">
- <label for="txtOut">Output from Task 3.3:</label>
- <input type="text" id = "txtBookTitle" value="Snømannen">
- <button id= "btnAddBook" onclick ="btnAddBookClick()" > Legg til bok!</button>
- <div style="padding: 10px; margin: 10px; min-width: 500px; border: darkblue thin solid; background-color: antiquewhite">
- <span id="txtOut" style="white-space:nowrap;"></span>
- </div>
- <script>
- "use strict";
- const DOMTextOut = document.getElementById("txtOut");
- const NEWLine = "\r\n";
- function printOut(aText) {
- if (DOMTextOut.innerText.length !== 0) {
- DOMTextOut.innerText += NEWLine;
- }
- DOMTextOut.innerText += aText;
- }
- const txtBookTitle = document.getElementById("txtBookTitle");
- function btnAddBookClick(){
- if (txtBookTitle.value === "Snømannen"){
- printOut("Dette er ingen bok");
- }else{
- printOut(txtBookTitle.value);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement